From 64961420ab103757909a002f950b202c5014dd8d Mon Sep 17 00:00:00 2001 From: kjgarza Date: Fri, 23 Oct 2020 17:08:35 +0200 Subject: [PATCH 1/7] avoid validation of exisiting providers --- app/validators/unique-provider-id.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/validators/unique-provider-id.js b/app/validators/unique-provider-id.js index b3ea0a310..10f29a31c 100644 --- a/app/validators/unique-provider-id.js +++ b/app/validators/unique-provider-id.js @@ -4,8 +4,8 @@ import BaseValidator from 'ember-cp-validations/validators/base'; const UniqueProviderId = BaseValidator.extend({ store: service(), - validate(value) { - if (value.length < 2) { + validate(value, options, model) { + if (value.length < 2 || !model.get('isNew')) { return true; } else { return this.store.query('provider', { id: value }).then((result) => { From 4555191c4f6451f96a293442aa9c537d7a80e2ce Mon Sep 17 00:00:00 2001 From: kjgarza Date: Fri, 23 Oct 2020 17:34:18 +0200 Subject: [PATCH 2/7] fix: use url validator rather than regexp --- app/components/doi-related-identifier.js | 4 ++-- app/validators/identifier-format.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/doi-related-identifier.js b/app/components/doi-related-identifier.js index 2135e66fb..b24da5744 100644 --- a/app/components/doi-related-identifier.js +++ b/app/components/doi-related-identifier.js @@ -110,7 +110,7 @@ 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 = /^http?:\/\/(purl\.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]/; @@ -151,7 +151,7 @@ export default Component.extend({ this.fragment.set('relatedIdentifierType', 'LSID'); this.set('controlledIdentifierType', true); break; - case purl.test(value): + case isURL(value, purl): this.fragment.set('relatedIdentifier', value); this.fragment.set('relatedIdentifierType', 'PURL'); this.set('controlledIdentifierType', true); diff --git a/app/validators/identifier-format.js b/app/validators/identifier-format.js index 6ebcb596c..5be937516 100644 --- a/app/validators/identifier-format.js +++ b/app/validators/identifier-format.js @@ -7,7 +7,7 @@ const IdentifierFormat = BaseValidator.extend({ validate(value, options, model) { 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 = /^http?:\/\/(purl\.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]/; @@ -26,7 +26,7 @@ const IdentifierFormat = BaseValidator.extend({ case model.relatedIdentifierType == 'LSID': return lsid.test(value) ? true : 'Please enter a valid LSID.'; case model.relatedIdentifierType == 'PURL': - return purl.test(value) ? true : 'Please enter a valid PURL.'; + return isURL(value, purl) ? true : 'Please enter a valid PURL.'; case model.relatedIdentifierType == 'URN': return urn.test(value) ? true : 'Please enter a valid URN.'; case model.relatedIdentifierType == 'ISBN': From a739eb19f187efba73294baac5d24615038ae1b9 Mon Sep 17 00:00:00 2001 From: kjgarza Date: Mon, 26 Oct 2020 06:36:48 +0100 Subject: [PATCH 3/7] style: lint --- app/components/doi-related-identifier.js | 2 +- app/validators/identifier-format.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/doi-related-identifier.js b/app/components/doi-related-identifier.js index b24da5744..ed9ea5e9f 100644 --- a/app/components/doi-related-identifier.js +++ b/app/components/doi-related-identifier.js @@ -110,7 +110,7 @@ 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]/; diff --git a/app/validators/identifier-format.js b/app/validators/identifier-format.js index 5be937516..4201638bd 100644 --- a/app/validators/identifier-format.js +++ b/app/validators/identifier-format.js @@ -7,7 +7,7 @@ const IdentifierFormat = BaseValidator.extend({ validate(value, options, model) { 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]/; From 0c407f01995bf8919fded2c02feb32f159e887cb Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Fri, 6 Nov 2020 16:05:38 +0100 Subject: [PATCH 4/7] Match known resource types in constants used e.g. its ResourceObject not Resource object, see schema --- app/components/doi-related-identifier.js | 275 ++++++++++++----------- app/components/doi-types.js | 40 ++-- app/validators/resource-type.js | 38 ++-- 3 files changed, 181 insertions(+), 172 deletions(-) diff --git a/app/components/doi-related-identifier.js b/app/components/doi-related-identifier.js index ed9ea5e9f..d3f3d8dce 100644 --- a/app/components/doi-related-identifier.js +++ b/app/components/doi-related-identifier.js @@ -1,84 +1,84 @@ /* eslint-disable no-useless-escape */ -import Component from '@ember/component'; -import { inject as service } from '@ember/service'; -import { isURL, isISBN } from 'validator'; -import { isBlank } from '@ember/utils'; -import { pascalCase } from 'pascal-case'; +import Component from "@ember/component"; +import { inject as service } from "@ember/service"; +import { isURL, isISBN } from "validator"; +import { isBlank } from "@ember/utils"; +import { pascalCase } from "pascal-case"; const relationTypeList = [ - 'Cites', - 'Is cited by', - 'Compiles', - 'Is compiled by', - 'Continues', - 'Is continued by', - 'Describes', - 'Is described by', - 'Documents', - 'Is documented by', - 'Is derived from', - 'Is source of', - 'Has metadata', - 'Is metadata for', - 'Has part', - 'Is part of', - 'Is supplemented by', - 'Is supplement to', - 'Obsoletes', - 'Is obsoleted by', - 'References', - 'Is referenced by', - 'Requires', - 'Is required by', - 'Reviews', - 'Is reviewed by', - 'Has version', - 'Is version of', - 'Is new version of', - 'Is previous version of', - 'Is variant form of', - 'Is original form of', - 'Is identical to', + "Cites", + "Is cited by", + "Compiles", + "Is compiled by", + "Continues", + "Is continued by", + "Describes", + "Is described by", + "Documents", + "Is documented by", + "Is derived from", + "Is source of", + "Has metadata", + "Is metadata for", + "Has part", + "Is part of", + "Is supplemented by", + "Is supplement to", + "Obsoletes", + "Is obsoleted by", + "References", + "Is referenced by", + "Requires", + "Is required by", + "Reviews", + "Is reviewed by", + "Has version", + "Is version of", + "Is new version of", + "Is previous version of", + "Is variant form of", + "Is original form of", + "Is identical to", ]; const relatedIdentifierTypeList = [ - 'ARK', - 'arXiv', - 'bibcode', - 'DOI', - 'EAN13', - 'EISSN', - 'Handle', - 'IGSN', - 'ISBN', - 'ISSN', - 'ISTC', - 'LISSN', - 'LSID', - 'PMID', - 'PURL', - 'UPC', - 'URL', - 'URN', - 'w3id', + "ARK", + "arXiv", + "bibcode", + "DOI", + "EAN13", + "EISSN", + "Handle", + "IGSN", + "ISBN", + "ISSN", + "ISTC", + "LISSN", + "LSID", + "PMID", + "PURL", + "UPC", + "URL", + "URN", + "w3id", ]; const resourceTypeGeneralList = [ - 'Audiovisual', - 'Collection', - 'DataPaper', - 'Dataset', - 'Event', - 'Image', - 'Interactive resource', - 'Model', - 'Physical object', - 'Service', - 'Software', - 'Sound', - 'Text', - 'Workflow', - 'Other', + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other", ]; export default Component.extend({ @@ -89,28 +89,37 @@ export default Component.extend({ relatedIdentifierTypes: relatedIdentifierTypeList, controlledIdentifierType: false, isMetadataRelationType: false, - isMetadataRelationTypes: [ 'HasMetadata', 'IsMetadataFor' ], + isMetadataRelationTypes: ["HasMetadata", "IsMetadataFor"], resourceTypeGeneralList, resourceTypesGeneral: resourceTypeGeneralList, didReceiveAttrs() { this._super(...arguments); - if (relatedIdentifierTypeList.includes(this.fragment.get('relatedIdentifierType'))) { - this.set('controlledIdentifierType', true); + if ( + relatedIdentifierTypeList.includes( + this.fragment.get("relatedIdentifierType") + ) + ) { + this.set("controlledIdentifierType", true); } else { - this.set('controlledIdentifierType', false); + this.set("controlledIdentifierType", false); } - if (this.isMetadataRelationTypes.includes(this.fragment.get('relationType'))) { - this.set('isMetadataRelationType', true); + if ( + this.isMetadataRelationTypes.includes(this.fragment.get("relationType")) + ) { + this.set("isMetadataRelationType", true); } else { - this.set('isMetadataRelationType', false); + this.set("isMetadataRelationType", false); } }, 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]/; @@ -118,53 +127,53 @@ export default Component.extend({ switch (true) { case isBlank(value): - this.fragment.set('relatedIdentifier', null); - this.fragment.set('relatedIdentifierType', null); - this.set('controlledIdentifierType', false); + this.fragment.set("relatedIdentifier", null); + this.fragment.set("relatedIdentifierType", null); + this.set("controlledIdentifierType", false); this.selectResourceTypeGeneral(null); - this.fragment.set('schemeType', null); - this.fragment.set('relatedMetadataScheme', null); - this.fragment.set('relationType', null); + this.fragment.set("schemeType", null); + this.fragment.set("relatedMetadataScheme", null); + this.fragment.set("relationType", null); break; case ark.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'ARK'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "ARK"); + this.set("controlledIdentifierType", true); break; case arxiv.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'arXiv'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "arXiv"); + this.set("controlledIdentifierType", true); break; case doi.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'DOI'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "DOI"); + this.set("controlledIdentifierType", true); break; case bibcode.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'bibcode'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "bibcode"); + this.set("controlledIdentifierType", true); break; case lsid.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'LSID'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "LSID"); + this.set("controlledIdentifierType", true); break; case isURL(value, purl): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'PURL'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "PURL"); + this.set("controlledIdentifierType", true); break; case urn.test(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'URN'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "URN"); + this.set("controlledIdentifierType", true); break; case isISBN(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'ISBN'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "ISBN"); + this.set("controlledIdentifierType", true); break; // // EAN currently not supported https://github.com/validatorjs/validator.js/issues/797 // case isEAN(value): @@ -173,52 +182,52 @@ export default Component.extend({ // this.set('controlledIdentifierType', true); // break; case isURL(value): - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', 'URL'); - this.set('controlledIdentifierType', true); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", "URL"); + this.set("controlledIdentifierType", true); break; default: // // Clears the relatedIdentifierType in case the user changes the relatedIdentifier after selecting it once before. - this.fragment.set('relatedIdentifier', value); - this.fragment.set('relatedIdentifierType', null); - this.fragment.set('relationType', null); - this.set('controlledIdentifierType', false); + this.fragment.set("relatedIdentifier", value); + this.fragment.set("relatedIdentifierType", null); + this.fragment.set("relationType", null); + this.set("controlledIdentifierType", false); break; } }, selectRelationType(relationType) { if (this.isMetadataRelationTypes.includes(relationType)) { - this.set('isMetadataRelationType', true); + this.set("isMetadataRelationType", true); } else { - this.set('isMetadataRelationType', false); - this.fragment.set('schemeType', null); - this.fragment.set('relatedMetadataScheme', null); - this.fragment.set('resourceTypeGeneral', null); - this.fragment.set('schemeUri', null); + this.set("isMetadataRelationType", false); + this.fragment.set("schemeType", null); + this.fragment.set("relatedMetadataScheme", null); + this.fragment.set("resourceTypeGeneral", null); + this.fragment.set("schemeUri", null); } - this.fragment.set('relationType', pascalCase(relationType)); - this.set('relationTypes', relationTypeList); + this.fragment.set("relationType", pascalCase(relationType)); + this.set("relationTypes", relationTypeList); }, selectRelatedIdentifierType(relatedIdentifierType) { - this.fragment.set('relatedIdentifierType', relatedIdentifierType); - this.set('relatedIdentifierTypes', relatedIdentifierTypeList); + this.fragment.set("relatedIdentifierType", relatedIdentifierType); + this.set("relatedIdentifierTypes", relatedIdentifierTypeList); }, selectResourceTypeGeneral(resourceTypeGeneral) { - this.fragment.set('resourceTypeGeneral', pascalCase(resourceTypeGeneral)); - this.set('resourceTypesGeneral', resourceTypeGeneralList); + this.fragment.set("resourceTypeGeneral", pascalCase(resourceTypeGeneral)); + this.set("resourceTypesGeneral", resourceTypeGeneralList); }, actions: { updateRelatedIdentifier(value) { this.updateRelatedIdentifier(value.trim()); }, updateRelatedMetadataScheme(value) { - this.fragment.set('relatedMetadataScheme', value); + this.fragment.set("relatedMetadataScheme", value); }, updateSchemeURI(value) { - this.fragment.set('schemeUri', value); + this.fragment.set("schemeUri", value); }, updateSchemeType(value) { - this.fragment.set('schemeType', value); + this.fragment.set("schemeType", value); }, selectRelationType(relationType) { this.selectRelationType(relationType); @@ -230,7 +239,7 @@ export default Component.extend({ this.selectResourceTypeGeneral(resourceTypeGeneral); }, deleteRelatedIdentifier() { - this.model.get('relatedIdentifiers').removeObject(this.fragment); + this.model.get("relatedIdentifiers").removeObject(this.fragment); }, }, }); diff --git a/app/components/doi-types.js b/app/components/doi-types.js index d255ed8bf..32e80375f 100644 --- a/app/components/doi-types.js +++ b/app/components/doi-types.js @@ -1,22 +1,22 @@ -import Component from '@ember/component'; -import { pascalCase } from 'pascal-case'; +import Component from "@ember/component"; +import { pascalCase } from "pascal-case"; const resourceTypeGeneralList = [ - 'Audiovisual', - 'Collection', - 'DataPaper', - 'Dataset', - 'Event', - 'Image', - 'Interactive resource', - 'Model', - 'Physical object', - 'Service', - 'Software', - 'Sound', - 'Text', - 'Workflow', - 'Other', + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other", ]; export default Component.extend({ @@ -24,8 +24,10 @@ export default Component.extend({ resourceTypesGeneral: resourceTypeGeneralList, selectResourceTypeGeneral(resourceTypeGeneral) { - this.model.set('types', { resourceTypeGeneral: pascalCase(resourceTypeGeneral) }); - this.set('resourceTypesGeneral', resourceTypeGeneralList); + this.model.set("types", { + resourceTypeGeneral: pascalCase(resourceTypeGeneral), + }); + this.set("resourceTypesGeneral", resourceTypeGeneralList); }, actions: { diff --git a/app/validators/resource-type.js b/app/validators/resource-type.js index 55789765f..8cec1fcf8 100644 --- a/app/validators/resource-type.js +++ b/app/validators/resource-type.js @@ -1,32 +1,30 @@ /* eslint-disable no-useless-escape */ -import BaseValidator from 'ember-cp-validations/validators/base'; +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', - 'Model', - 'Physical object', - 'Service', - 'Software', - 'Sound', - 'Text', - 'Workflow', - 'Other', + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other", ]; - const message = 'Resource of the Type is not valid.'; + 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; From e814a6db975440a79fc8c3ed21ca2240024815ab Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Fri, 6 Nov 2020 16:30:58 +0100 Subject: [PATCH 5/7] Update refresh icon to work on 5 Font-awesome 5 doesnt have old refresh replaced with sync --- app/templates/components/provider-id.hbs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/templates/components/provider-id.hbs b/app/templates/components/provider-id.hbs index 226a8ce1a..4fe6262de 100644 --- a/app/templates/components/provider-id.hbs +++ b/app/templates/components/provider-id.hbs @@ -1,19 +1,21 @@
- Click the circle icon for a new random ID, or the cross icon to delete the random ID and enter a value manually. + Click the refresh icon for a new random ID, or the cross icon to delete the random ID and enter a value manually.
-{{#form.element +{{#form.element controlType="text" id="member-id" label="Member ID" property="symbol" helpText="The Member ID is the unique identifier for each member and can't be changed. The Member ID can contain only upper case letters, and must not be longer than 8 characters." required=false as |el|}} - -
- {{el.control}} - - -
-{{/form.element}} +
+ {{el.control}} + + + +
+{{/form.element}} \ No newline at end of file From 5356c1606a8660adf28c2ab8b874b432812ee97f Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Mon, 9 Nov 2020 09:49:00 +0100 Subject: [PATCH 6/7] Apply eslint rules for fix --- app/components/doi-related-identifier.js | 266 +++++++++++------------ app/components/doi-types.js | 38 ++-- app/validators/resource-type.js | 34 +-- 3 files changed, 169 insertions(+), 169 deletions(-) diff --git a/app/components/doi-related-identifier.js b/app/components/doi-related-identifier.js index d3f3d8dce..dfbbca7a7 100644 --- a/app/components/doi-related-identifier.js +++ b/app/components/doi-related-identifier.js @@ -1,84 +1,84 @@ /* eslint-disable no-useless-escape */ -import Component from "@ember/component"; -import { inject as service } from "@ember/service"; -import { isURL, isISBN } from "validator"; -import { isBlank } from "@ember/utils"; -import { pascalCase } from "pascal-case"; +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; +import { isURL, isISBN } from 'validator'; +import { isBlank } from '@ember/utils'; +import { pascalCase } from 'pascal-case'; const relationTypeList = [ - "Cites", - "Is cited by", - "Compiles", - "Is compiled by", - "Continues", - "Is continued by", - "Describes", - "Is described by", - "Documents", - "Is documented by", - "Is derived from", - "Is source of", - "Has metadata", - "Is metadata for", - "Has part", - "Is part of", - "Is supplemented by", - "Is supplement to", - "Obsoletes", - "Is obsoleted by", - "References", - "Is referenced by", - "Requires", - "Is required by", - "Reviews", - "Is reviewed by", - "Has version", - "Is version of", - "Is new version of", - "Is previous version of", - "Is variant form of", - "Is original form of", - "Is identical to", + 'Cites', + 'Is cited by', + 'Compiles', + 'Is compiled by', + 'Continues', + 'Is continued by', + 'Describes', + 'Is described by', + 'Documents', + 'Is documented by', + 'Is derived from', + 'Is source of', + 'Has metadata', + 'Is metadata for', + 'Has part', + 'Is part of', + 'Is supplemented by', + 'Is supplement to', + 'Obsoletes', + 'Is obsoleted by', + 'References', + 'Is referenced by', + 'Requires', + 'Is required by', + 'Reviews', + 'Is reviewed by', + 'Has version', + 'Is version of', + 'Is new version of', + 'Is previous version of', + 'Is variant form of', + 'Is original form of', + 'Is identical to', ]; const relatedIdentifierTypeList = [ - "ARK", - "arXiv", - "bibcode", - "DOI", - "EAN13", - "EISSN", - "Handle", - "IGSN", - "ISBN", - "ISSN", - "ISTC", - "LISSN", - "LSID", - "PMID", - "PURL", - "UPC", - "URL", - "URN", - "w3id", + 'ARK', + 'arXiv', + 'bibcode', + 'DOI', + 'EAN13', + 'EISSN', + 'Handle', + 'IGSN', + 'ISBN', + 'ISSN', + 'ISTC', + 'LISSN', + 'LSID', + 'PMID', + 'PURL', + 'UPC', + 'URL', + 'URN', + 'w3id', ]; const resourceTypeGeneralList = [ - "Audiovisual", - "Collection", - "DataPaper", - "Dataset", - "Event", - "Image", - "InteractiveResource", - "Model", - "PhysicalObject", - "Service", - "Software", - "Sound", - "Text", - "Workflow", - "Other", + 'Audiovisual', + 'Collection', + 'DataPaper', + 'Dataset', + 'Event', + 'Image', + 'InteractiveResource', + 'Model', + 'PhysicalObject', + 'Service', + 'Software', + 'Sound', + 'Text', + 'Workflow', + 'Other', ]; export default Component.extend({ @@ -89,7 +89,7 @@ export default Component.extend({ relatedIdentifierTypes: relatedIdentifierTypeList, controlledIdentifierType: false, isMetadataRelationType: false, - isMetadataRelationTypes: ["HasMetadata", "IsMetadataFor"], + isMetadataRelationTypes: [ 'HasMetadata', 'IsMetadataFor' ], resourceTypeGeneralList, resourceTypesGeneral: resourceTypeGeneralList, @@ -98,19 +98,19 @@ export default Component.extend({ if ( relatedIdentifierTypeList.includes( - this.fragment.get("relatedIdentifierType") + this.fragment.get('relatedIdentifierType'), ) ) { - this.set("controlledIdentifierType", true); + this.set('controlledIdentifierType', true); } else { - this.set("controlledIdentifierType", false); + this.set('controlledIdentifierType', false); } if ( - this.isMetadataRelationTypes.includes(this.fragment.get("relationType")) + this.isMetadataRelationTypes.includes(this.fragment.get('relationType')) ) { - this.set("isMetadataRelationType", true); + this.set('isMetadataRelationType', true); } else { - this.set("isMetadataRelationType", false); + this.set('isMetadataRelationType', false); } }, updateRelatedIdentifier(value) { @@ -118,7 +118,7 @@ export default Component.extend({ 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"], + 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}\/.+)/; @@ -127,53 +127,53 @@ export default Component.extend({ switch (true) { case isBlank(value): - this.fragment.set("relatedIdentifier", null); - this.fragment.set("relatedIdentifierType", null); - this.set("controlledIdentifierType", false); + this.fragment.set('relatedIdentifier', null); + this.fragment.set('relatedIdentifierType', null); + this.set('controlledIdentifierType', false); this.selectResourceTypeGeneral(null); - this.fragment.set("schemeType", null); - this.fragment.set("relatedMetadataScheme", null); - this.fragment.set("relationType", null); + this.fragment.set('schemeType', null); + this.fragment.set('relatedMetadataScheme', null); + this.fragment.set('relationType', null); break; case ark.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "ARK"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'ARK'); + this.set('controlledIdentifierType', true); break; case arxiv.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "arXiv"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'arXiv'); + this.set('controlledIdentifierType', true); break; case doi.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "DOI"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'DOI'); + this.set('controlledIdentifierType', true); break; case bibcode.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "bibcode"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'bibcode'); + this.set('controlledIdentifierType', true); break; case lsid.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "LSID"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'LSID'); + this.set('controlledIdentifierType', true); break; case isURL(value, purl): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "PURL"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'PURL'); + this.set('controlledIdentifierType', true); break; case urn.test(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "URN"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'URN'); + this.set('controlledIdentifierType', true); break; case isISBN(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "ISBN"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'ISBN'); + this.set('controlledIdentifierType', true); break; // // EAN currently not supported https://github.com/validatorjs/validator.js/issues/797 // case isEAN(value): @@ -182,52 +182,52 @@ export default Component.extend({ // this.set('controlledIdentifierType', true); // break; case isURL(value): - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", "URL"); - this.set("controlledIdentifierType", true); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', 'URL'); + this.set('controlledIdentifierType', true); break; default: // // Clears the relatedIdentifierType in case the user changes the relatedIdentifier after selecting it once before. - this.fragment.set("relatedIdentifier", value); - this.fragment.set("relatedIdentifierType", null); - this.fragment.set("relationType", null); - this.set("controlledIdentifierType", false); + this.fragment.set('relatedIdentifier', value); + this.fragment.set('relatedIdentifierType', null); + this.fragment.set('relationType', null); + this.set('controlledIdentifierType', false); break; } }, selectRelationType(relationType) { if (this.isMetadataRelationTypes.includes(relationType)) { - this.set("isMetadataRelationType", true); + this.set('isMetadataRelationType', true); } else { - this.set("isMetadataRelationType", false); - this.fragment.set("schemeType", null); - this.fragment.set("relatedMetadataScheme", null); - this.fragment.set("resourceTypeGeneral", null); - this.fragment.set("schemeUri", null); + this.set('isMetadataRelationType', false); + this.fragment.set('schemeType', null); + this.fragment.set('relatedMetadataScheme', null); + this.fragment.set('resourceTypeGeneral', null); + this.fragment.set('schemeUri', null); } - this.fragment.set("relationType", pascalCase(relationType)); - this.set("relationTypes", relationTypeList); + this.fragment.set('relationType', pascalCase(relationType)); + this.set('relationTypes', relationTypeList); }, selectRelatedIdentifierType(relatedIdentifierType) { - this.fragment.set("relatedIdentifierType", relatedIdentifierType); - this.set("relatedIdentifierTypes", relatedIdentifierTypeList); + this.fragment.set('relatedIdentifierType', relatedIdentifierType); + this.set('relatedIdentifierTypes', relatedIdentifierTypeList); }, selectResourceTypeGeneral(resourceTypeGeneral) { - this.fragment.set("resourceTypeGeneral", pascalCase(resourceTypeGeneral)); - this.set("resourceTypesGeneral", resourceTypeGeneralList); + this.fragment.set('resourceTypeGeneral', pascalCase(resourceTypeGeneral)); + this.set('resourceTypesGeneral', resourceTypeGeneralList); }, actions: { updateRelatedIdentifier(value) { this.updateRelatedIdentifier(value.trim()); }, updateRelatedMetadataScheme(value) { - this.fragment.set("relatedMetadataScheme", value); + this.fragment.set('relatedMetadataScheme', value); }, updateSchemeURI(value) { - this.fragment.set("schemeUri", value); + this.fragment.set('schemeUri', value); }, updateSchemeType(value) { - this.fragment.set("schemeType", value); + this.fragment.set('schemeType', value); }, selectRelationType(relationType) { this.selectRelationType(relationType); @@ -239,7 +239,7 @@ export default Component.extend({ this.selectResourceTypeGeneral(resourceTypeGeneral); }, deleteRelatedIdentifier() { - this.model.get("relatedIdentifiers").removeObject(this.fragment); + this.model.get('relatedIdentifiers').removeObject(this.fragment); }, }, }); diff --git a/app/components/doi-types.js b/app/components/doi-types.js index 32e80375f..3386fee73 100644 --- a/app/components/doi-types.js +++ b/app/components/doi-types.js @@ -1,22 +1,22 @@ -import Component from "@ember/component"; -import { pascalCase } from "pascal-case"; +import Component from '@ember/component'; +import { pascalCase } from 'pascal-case'; const resourceTypeGeneralList = [ - "Audiovisual", - "Collection", - "DataPaper", - "Dataset", - "Event", - "Image", - "InteractiveResource", - "Model", - "PhysicalObject", - "Service", - "Software", - "Sound", - "Text", - "Workflow", - "Other", + 'Audiovisual', + 'Collection', + 'DataPaper', + 'Dataset', + 'Event', + 'Image', + 'InteractiveResource', + 'Model', + 'PhysicalObject', + 'Service', + 'Software', + 'Sound', + 'Text', + 'Workflow', + 'Other', ]; export default Component.extend({ @@ -24,10 +24,10 @@ export default Component.extend({ resourceTypesGeneral: resourceTypeGeneralList, selectResourceTypeGeneral(resourceTypeGeneral) { - this.model.set("types", { + this.model.set('types', { resourceTypeGeneral: pascalCase(resourceTypeGeneral), }); - this.set("resourceTypesGeneral", resourceTypeGeneralList); + this.set('resourceTypesGeneral', resourceTypeGeneralList); }, actions: { diff --git a/app/validators/resource-type.js b/app/validators/resource-type.js index 8cec1fcf8..5dac24e5e 100644 --- a/app/validators/resource-type.js +++ b/app/validators/resource-type.js @@ -1,27 +1,27 @@ /* eslint-disable no-useless-escape */ -import BaseValidator from "ember-cp-validations/validators/base"; +import BaseValidator from 'ember-cp-validations/validators/base'; const ResourceType = BaseValidator.extend({ validate(value, options) { const resourceTypeGeneralList = [ - "Audiovisual", - "Collection", - "DataPaper", - "Dataset", - "Event", - "Image", - "InteractiveResource", - "Model", - "PhysicalObject", - "Service", - "Software", - "Sound", - "Text", - "Workflow", - "Other", + 'Audiovisual', + 'Collection', + 'DataPaper', + 'Dataset', + 'Event', + 'Image', + 'InteractiveResource', + 'Model', + 'PhysicalObject', + 'Service', + 'Software', + 'Sound', + 'Text', + 'Workflow', + 'Other', ]; - const message = "Resource of the Type is not valid."; + const message = 'Resource of the Type is not valid.'; switch (true) { case !value && options.allowBlank: From baa9191ea404d9db45d493269af0badb1b5cea39 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Wed, 11 Nov 2020 12:42:56 +0100 Subject: [PATCH 7/7] Update test --- tests/integration/components/provider-id-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/components/provider-id-test.js b/tests/integration/components/provider-id-test.js index ac3d0d74b..14eee4e3f 100644 --- a/tests/integration/components/provider-id-test.js +++ b/tests/integration/components/provider-id-test.js @@ -13,6 +13,6 @@ module('Integration | Component | provider-id', function(hooks) { await render(hbs`{{provider-id model=model}}`); - assert.dom(this.element).hasText('Click the circle icon for a new random ID, or the cross icon to delete the random ID and enter a value manually.'); + assert.dom(this.element).hasText('Click the refresh icon for a new random ID, or the cross icon to delete the random ID and enter a value manually.'); }); });