Skip to content

Commit

Permalink
Merge pull request #481 from datacite/fix_resource_types
Browse files Browse the repository at this point in the history
Match known resource types in constants used
  • Loading branch information
richardhallett authored Nov 9, 2020
2 parents e814a6d + 5356c16 commit 5dac356
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
19 changes: 14 additions & 5 deletions app/components/doi-related-identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ const resourceTypeGeneralList = [
'Dataset',
'Event',
'Image',
'Interactive resource',
'InteractiveResource',
'Model',
'Physical object',
'PhysicalObject',
'Service',
'Software',
'Sound',
Expand All @@ -96,12 +96,18 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);

if (relatedIdentifierTypeList.includes(this.fragment.get('relatedIdentifierType'))) {
if (
relatedIdentifierTypeList.includes(
this.fragment.get('relatedIdentifierType'),
)
) {
this.set('controlledIdentifierType', true);
} else {
this.set('controlledIdentifierType', false);
}
if (this.isMetadataRelationTypes.includes(this.fragment.get('relationType'))) {
if (
this.isMetadataRelationTypes.includes(this.fragment.get('relationType'))
) {
this.set('isMetadataRelationType', true);
} else {
this.set('isMetadataRelationType', false);
Expand All @@ -110,7 +116,10 @@ export default Component.extend({
updateRelatedIdentifier(value) {
const ark = /^ark:\/[0-9]{5}\/\S+$/;
const lsid = /^[uU][rR][nN]:[lL][sS][iI][dD]:(A-Za-z0-9][A-Za-z0-9()+,-.=@;$_!*'"%]):(A-Za-z0-9][A-Za-z0-9()+,-.=@;$_!*'"%]):(A-Za-z0-9][A-Za-z0-9()+,-.=@;$_!*'"%])[:]?(A-Za-z0-9][A-Za-z0-9()+,-.=@;$_!*'"%])?$/;
const purl = {require_host: true, host_whitelist: [ 'purl.org', 'oclc.org' ]};
const purl = {
require_host: true,
host_whitelist: [ 'purl.org', 'oclc.org' ],
};
const arxiv = /^(arXiv:)(\d{4}.\d{4,5}|[a-z\-]+(\.[A-Z]{2})?\/\d{7})(v\d+)?/;
const doi = /^(10\.\d{4,5}\/.+)/;
const bibcode = /\d{4}[A-Za-z\.\&]{5}[\w\.]{4}[ELPQ-Z\.][\d\.]{4}[A-Z]/;
Expand Down
8 changes: 5 additions & 3 deletions app/components/doi-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const resourceTypeGeneralList = [
'Dataset',
'Event',
'Image',
'Interactive resource',
'InteractiveResource',
'Model',
'Physical object',
'PhysicalObject',
'Service',
'Software',
'Sound',
Expand All @@ -24,7 +24,9 @@ export default Component.extend({
resourceTypesGeneral: resourceTypeGeneralList,

selectResourceTypeGeneral(resourceTypeGeneral) {
this.model.set('types', { resourceTypeGeneral: pascalCase(resourceTypeGeneral) });
this.model.set('types', {
resourceTypeGeneral: pascalCase(resourceTypeGeneral),
});
this.set('resourceTypesGeneral', resourceTypeGeneralList);
},

Expand Down
8 changes: 3 additions & 5 deletions app/validators/resource-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
import BaseValidator from 'ember-cp-validations/validators/base';

const ResourceType = BaseValidator.extend({

validate(value, options) {

const resourceTypeGeneralList = [
'Audiovisual',
'Collection',
'DataPaper',
'Dataset',
'Event',
'Image',
'Interactive resource',
'InteractiveResource',
'Model',
'Physical object',
'PhysicalObject',
'Service',
'Software',
'Sound',
Expand All @@ -26,7 +24,7 @@ const ResourceType = BaseValidator.extend({
const message = 'Resource of the Type is not valid.';

switch (true) {
case (!value && options.allowBlank):
case !value && options.allowBlank:
return true;
case resourceTypeGeneralList.includes(String(value)):
return true;
Expand Down

0 comments on commit 5dac356

Please sign in to comment.