Skip to content

Commit

Permalink
use name-identifier. #158
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Mar 8, 2019
1 parent 8bacf5b commit 95eafdc
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app/components/doi-name-identifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Component from '@ember/component';

const nameIdentifierSchemeList = [
'ISNI',
'ORCID'
];

const nameIdentifierSchemeOrganizationList = [
'ISNI',
'ROR'
];

const schemeUriList = {
isni: 'ISNI',
orcid: 'ORCID',
ror: 'ROR'
};

export default Component.extend({
nameIdentifierSchemeList,
nameIdentifierSchemes: nameIdentifierSchemeList,

actions: {
searchNameIdentifierScheme(query) {
var nameIdentifierSchemes = nameIdentifierSchemeList.filter(function (nameIdentifierScheme) {
return nameIdentifierScheme.toLowerCase().startsWith(query.toLowerCase());
})
this.set('nameIdentifierSchemes', nameIdentifierSchemes);
},
selectNameIdentifierScheme(nameIdentifierScheme) {
this.fragment.set('nameIdentifierScheme', nameIdentifierScheme);
this.fragment.set('schemeUri', schemeUriList[nameIdentifierScheme]);
this.set('nameIdentifierSchemes', nameIdentifierSchemeList);
}
}
});
8 changes: 8 additions & 0 deletions app/models/name-identifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import attr from 'ember-data/attr';
import Fragment from 'ember-data-model-fragments/fragment';

export default Fragment.extend({
nameIdentifier: attr('string'),
nameIdentifierScheme: attr('string'),
schemeUri: attr('string')
});
43 changes: 43 additions & 0 deletions app/templates/components/doi-name-identifier.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{#if (gt index 0)}}
<div class="col-md-9 col-md-offset-3">
<div class="input-group">
<input type="text" class="form-control {{if errorMessage 'has-error'}} {{if isValidating 'has-success'}} title-field" value={{fragment.title}} oninput={{action "updateTitle" value="target.value"}} onblur={{action "validateTitle"}} disabled={{disabled}}/>
<span class="input-group-btn">
{{#bs-button outline=true onClick=(action "deleteNameIdentifier" index)}}{{fa-icon "trash"}}{{/bs-button}}
</span>
</div>

{{#if errorMessage}}
<div class="help-block help-block-fragment has-error">{{errorMessage}}</div>
{{else}}
<div class="help-block help-block-fragment name-identifier-field">Uniquely identifies an individual or legal entity, according to various schemas.</div>
{{/if}}
</div>
{{else}}
<label class="control-label col-md-3">Name Identifiers</label>
<div class="col-md-9">
<input type="text" class="form-control {{if errorMessage 'has-error'}} {{if isValidating 'has-success'}} name-identifier-field" value={{fragment.nameIdentifier}} oninput={{action "updateNameIdentifier" value="target.value"}} onblur={{action "validateNameIdentifier"}}/>

{{#if errorMessage}}
<div class="help-block help-block-fragment has-error">{{errorMessage}}</div>
{{else}}
<div class="help-block help-block-fragment">Uniquely identifies an individual or legal entity, according to various schemas.</div>
{{/if}}
</div>
{{/if}}

<div class="power-select-label">
<div class="col-md-9 col-md-offset-3">
<label for="nameIdentifierScheme" class="subtitle">Name Identifier Scheme (optional)</label>
</div>
</div>

<div class="power-select-fragment">
{{#form.element controlType="power-select" value=fragment.nameIdentifierScheme options=nameIdentifierSchemes destination=fragment.nameIdentifierScheme disabled=disabled as |el|}}
{{#el.control onChange=(action "selectNameIdentifierScheme") search=(action "searchNameIdentifierScheme") placeholder="Select Name Identifier Scheme" searchPlaceholder="Type to search..." allowClear=true as |item|}}
{{item}}
{{/el.control}}
{{/form.element}}
</div>

<div class="col-md-9 col-md-offset-3"><hr /></div>
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = function(environment) {
ORCID_URL: process.env.ORCID_URL || "https://sandbox.orcid.org",
API_URL: process.env.API_URL || "https://api.test.datacite.org",
RE3DATA_API_URL: process.env.RE3DATA_API_URL || "https://api.test.datacite.org",
ROR_API_URL: process.env.ROR_API_URL || "https://api.ror.org",
EVENTDATA_URL: process.env.EVENTDATA_URL || "https://api.test.datacite.org",
CDN_URL: process.env.CDN_URL || "https://assets.test.datacite.org",
JWT_PUBLIC_KEY: process.env.JWT_PUBLIC_KEY || null,
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/components/doi-name-identifier-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// import { module, test } from 'qunit';
// import { setupRenderingTest } from 'ember-qunit';
// import { render } from '@ember/test-helpers';
// import hbs from 'htmlbars-inline-precompile';

// module('Integration | Component | doi-name-identifier', function(hooks) {
// setupRenderingTest(hooks);

// test('it renders', async function(assert) {
// // Set any properties with this.set('myProperty', 'value');
// // Handle any actions with this.set('myAction', function(val) { ... });

// await render(hbs`{{doi-name-identifier}}`);

// assert.equal(this.element.textContent.trim(), '');

// // Template block usage:
// await render(hbs`
// {{#doi-name-identifier}}
// template block text
// {{/doi-name-identifier}}
// `);

// assert.equal(this.element.textContent.trim(), 'template block text');
// });
// });

0 comments on commit 95eafdc

Please sign in to comment.