Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
i18n="@@works.onlyIdentifierTypesFundedBy"
*ngIf="externalIdForm.hasError('funded_by_invalid')"
>
Only identifier types "grant number", "doi", "uri" or "proposal id" are
allowed when using "funded-by" identifiers</mat-error
Only identifier types "grant number", "doi", "RRID", "uri" or "proposal
id" are allowed when using "funded-by" identifiers</mat-error
>

<mat-error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'

import { WorkIdentifiers } from './work-identifiers.validator'
import { WorkRelationships } from '../../../types/works.endpoint'

describe('WorkIdentifiers.fundedByInvalidRelationship', () => {
let formBuilder: UntypedFormBuilder

beforeEach(() => {
formBuilder = new UntypedFormBuilder()
})

function buildForm(
externalIdentifierType: string,
externalRelationship: string
): UntypedFormGroup {
const form = formBuilder.group({
externalIdentifierType: [externalIdentifierType],
externalRelationship: [externalRelationship],
})
form.setValidators([WorkIdentifiers.fundedByInvalidRelationship()])
form.updateValueAndValidity()
return form
}

it('allows rrid identifiers on a funded-by relationship', () => {
const form = buildForm('rrid', WorkRelationships['funded-by'])
expect(form.hasError('funded_by_invalid')).toBeFalse()
})

it('allows the previously supported identifier types on a funded-by relationship', () => {
;['grant_number', 'doi', 'uri', 'proposal-id'].forEach((type) => {
const form = buildForm(type, WorkRelationships['funded-by'])
expect(form.hasError('funded_by_invalid')).toBeFalse()
})
})

it('rejects unsupported identifier types on a funded-by relationship', () => {
;['isbn', 'handle', 'other-id', 'source-work-id'].forEach((type) => {
const form = buildForm(type, WorkRelationships['funded-by'])
expect(form.hasError('funded_by_invalid')).toBeTrue()
})
})

it('does not restrict identifier types on other relationships', () => {
const form = buildForm('isbn', WorkRelationships.self)
expect(form.hasError('funded_by_invalid')).toBeFalse()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class WorkIdentifiers {
return (c: AbstractControl): { [key: string]: boolean } | null => {
if (c.get('externalRelationship')?.value === 'funded-by') {
if (
['grant_number', 'doi', 'uri', 'proposal-id'].indexOf(
['grant_number', 'doi', 'uri', 'proposal-id', 'rrid'].indexOf(
c.get('externalIdentifierType')?.value
) >= 0
) {
Expand Down
2 changes: 1 addition & 1 deletion src/locale/messages.source.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -14327,7 +14327,7 @@
</context-group>
</trans-unit>
<trans-unit id="works.onlyIdentifierTypesFundedBy" datatype="html" resname="works.onlyIdentifierTypesFundedBy">
<source>Only identifier types "grant number", "doi", "uri" or "proposal id" are allowed when using "funded-by" identifiers</source>
<source>Only identifier types "grant number", "doi", "RRID", "uri" or "proposal id" are allowed when using "funded-by" identifiers</source>
<target>works.onlyIdentifierTypesFundedBy</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/record/components/work-external-identifiers-edit/work-external-identifiers-edit.component.html</context>
Expand Down
2 changes: 1 addition & 1 deletion src/locale/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -13562,7 +13562,7 @@
</context-group>
</trans-unit>
<trans-unit id="works.onlyIdentifierTypesFundedBy" datatype="html" resname="works.onlyIdentifierTypesFundedBy">
<source>Only identifier types "grant number", "doi", "uri" or "proposal id" are allowed when using "funded-by" identifiers</source>
<source>Only identifier types "grant number", "doi", "RRID", "uri" or "proposal id" are allowed when using "funded-by" identifiers</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/record/components/work-external-identifiers-edit/work-external-identifiers-edit.component.html</context>
<context context-type="linenumber">255,257</context>
Expand Down
2 changes: 1 addition & 1 deletion src/locale/properties/works/works.en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ works.addPubmed=Add PubMed ID
works.addBibtex=Add BibTeX
works.worksToExport=works to export
works.pleaseEnterExternalID=Please enter an external ID
works.onlyIdentifierTypesFundedBy=Only identifier types "grant number", "doi", "uri" or "proposal id" are allowed when using "funded-by" identifiers
works.onlyIdentifierTypesFundedBy=Only identifier types "grant number", "doi", "RRID", "uri" or "proposal id" are allowed when using "funded-by" identifiers
works.publisher=Publisher
works.conferenceTitle=Conference title
works.bookTitle=Book title
Expand Down
Loading