Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/bracco
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 19, 2020
2 parents 8953c34 + baa9191 commit 40ba535
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 28 deletions.
21 changes: 15 additions & 6 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 = /^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]/;
Expand Down Expand Up @@ -151,7 +160,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);
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
20 changes: 11 additions & 9 deletions app/templates/components/provider-id.hbs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<div class="col-md-9 col-md-offset-3 label-small">
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.
</div>

{{#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|}}

<div class="input-group-no-float">
{{el.control}}

<span class="input-group-addon refresh-input" title="Refresh" aria-label="Refresh" {{action 'refresh'}}><i class="fas fa-refresh"></i></span>
<span class="input-group-addon clear-input" title="Clear" aria-label="Clear" {{action 'clear'}}><i class="fas fa-times-circle"></i></span>
</div>
{{/form.element}}
<div class="input-group-no-float">
{{el.control}}

<span class="input-group-addon refresh-input" title="Refresh" aria-label="Refresh" {{action 'refresh'}}><i
class="fas fa-sync"></i></span>
<span class="input-group-addon clear-input" title="Clear" aria-label="Clear" {{action 'clear'}}><i
class="fas fa-times-circle"></i></span>
</div>
{{/form.element}}
4 changes: 2 additions & 2 deletions app/validators/identifier-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]/;
Expand All @@ -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':
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
4 changes: 2 additions & 2 deletions app/validators/unique-provider-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/provider-id-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
});
});

0 comments on commit 40ba535

Please sign in to comment.