-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Fenner
committed
Mar 8, 2019
1 parent
8bacf5b
commit 95eafdc
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
// }); | ||
// }); |