-
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.
Merge pull request #383 from datacite/feature_funderID
Feature funder ID
- Loading branch information
Showing
83 changed files
with
3,721 additions
and
2,526 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,22 @@ | ||
import JSONAPIAdapter from '@ember-data/adapter/json-api'; | ||
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; | ||
import ENV from 'bracco/config/environment'; | ||
|
||
export default JSONAPIAdapter.extend(DataAdapterMixin, { | ||
host: ENV.CROSSREF_API_URL, | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
this.set('headers', { | ||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', | ||
}); | ||
}, | ||
|
||
authorize() { | ||
}, | ||
|
||
pathForType() { | ||
return 'funders'; | ||
}, | ||
}); |
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
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,113 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { isBlank } from '@ember/utils'; | ||
|
||
const funderIdentifierTypeList = [ | ||
'Crossref Funder ID', | ||
'GRID', | ||
'ISNI', | ||
'ROR', | ||
'Other', | ||
]; | ||
|
||
export default Component.extend({ | ||
funderIdentifierTypeList, | ||
funderIdentifierTypes: funderIdentifierTypeList, | ||
isCrossrefId: false, | ||
selected: [], | ||
store: service(), | ||
|
||
funders: [], | ||
|
||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
|
||
if (funderIdentifierTypeList.includes(this.fragment.get('subject'))) { | ||
this.set('isCrossrefId', true); | ||
} else { | ||
this.set('isCrossrefId', false); | ||
} | ||
}, | ||
updateFunderSchemeAndType(scheme) { | ||
switch (scheme) { | ||
case scheme == 'ROR': | ||
this.fragment.set('funderIdentifierType', 'ROR'); | ||
break; | ||
case scheme == 'Crossref Funder ID': | ||
this.fragment.set('funderIdentifierType', 'Crossref Funder ID'); | ||
break; | ||
case scheme == 'GRID': | ||
this.fragment.set('relatedIdentifierType', 'GRID'); | ||
break; | ||
case scheme == 'ISNI': | ||
this.fragment.set('funderIdentifierType', 'ISNI'); | ||
break; | ||
default: | ||
this.fragment.set('funderIdentifierType', 'Other'); | ||
break; | ||
} | ||
}, | ||
updateFunderReference(funder) { | ||
if (funder.uri) { | ||
this.fragment.set('funderName', funder.name); | ||
this.fragment.set('funderIdentifierType', 'Crossref Funder ID'); | ||
this.fragment.set('schemeUri', 'https://www.crossref.org/services/funder-registry/'); | ||
this.fragment.set('funderIdentifier', funder.uri); | ||
this.set('isCrossrefId', true); | ||
} else { | ||
this.fragment.set('funderIdentifierType', 'Other'); | ||
this.fragment.set('funderIdentifier', null); | ||
this.fragment.set('funderName', funder); | ||
this.updateFunderSchemeAndType(null); | ||
this.set('isCrossrefId', false); | ||
} | ||
}, | ||
|
||
actions: { | ||
createOnEnter(select, e) { | ||
if (e.keyCode === 13 && select.isOpen && !select.highlighted && !isBlank(select.searchText)) { | ||
if (!this.selected.includes(select.searchText)) { | ||
this.funderIdentifierTypes.push(select.searchText); | ||
select.actions.choose(select.searchText); | ||
this.fragment.set('funderName', select.searchText); | ||
this.fragment.set('funderIdentifierType', 'Other'); | ||
this.set('funderIdentifierTypes', funderIdentifierTypeList); | ||
} | ||
} | ||
}, | ||
updateFunderIdentifier(value) { | ||
this.fragment.set('funderIdentifier', value); | ||
}, | ||
selectFunderReference(value) { | ||
this.updateFunderReference(value); | ||
}, | ||
updateFunderName(value) { | ||
this.fragment.set('funderName', value); | ||
}, | ||
selectFunderIdentifierType(value) { | ||
this.fragment.set('funderIdentifierType', value); | ||
}, | ||
updateSchemeUri(value) { | ||
this.fragment.set('schemeUri', value); | ||
}, | ||
updateAwardNumber(value) { | ||
this.fragment.set('awardNumber', value); | ||
}, | ||
updateAwardTitle(value) { | ||
this.fragment.set('awardTitle', value); | ||
}, | ||
updateAwardUri(value) { | ||
this.fragment.set('awardUri', value); | ||
}, | ||
deleteFundingReference() { | ||
this.model.get('fundingReferences').removeObject(this.fragment); | ||
}, | ||
searchFundingReferences(query) { | ||
let self = this; | ||
this.store.query('funder', { query }).then(function(funders) { | ||
self.set('funders', funders); | ||
}); | ||
}, | ||
}, | ||
}); | ||
|
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,22 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
validationClass: null, | ||
|
||
didReceiveAttrs() { | ||
this._super(...arguments); | ||
|
||
if (!this.model.get('fundingReferences')) { | ||
this.model.set('fundingReferences', []); | ||
} | ||
if (this.model.get('fundingReferences').length == 0) { | ||
this.model.get('fundingReferences').createFragment(); | ||
} | ||
}, | ||
|
||
actions: { | ||
addFundingReference() { | ||
this.model.get('fundingReferences').createFragment(); | ||
}, | ||
}, | ||
}); |
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
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
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,10 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
|
||
export default Model.extend({ | ||
meta: attr(), | ||
|
||
funderId: attr('string'), | ||
name: attr('string'), | ||
uri: attr('string'), | ||
location: 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,35 @@ | ||
import DS from 'ember-data'; | ||
import Fragment from 'ember-data-model-fragments/fragment'; | ||
import { validator, buildValidations } from 'ember-cp-validations'; | ||
import { computed } from '@ember/object'; | ||
|
||
const Validations = buildValidations({ | ||
funderName: [ | ||
validator('presence', { | ||
presence: true, | ||
isWarning: computed('model.state', function() { | ||
return this.model.get('state') === 'draft'; | ||
}), | ||
disabled: computed('model.funderIdentifier', function() { | ||
return this.model.get('funderIdentifier') == null; | ||
}), | ||
}), | ||
], | ||
awardUri: [ | ||
validator('url-format', { | ||
allowBlank: true, | ||
require_tld: false, | ||
message: 'Please enter a valid URL.', | ||
}), | ||
], | ||
}); | ||
|
||
export default Fragment.extend(Validations, { | ||
funderName: DS.attr('string', { defaultValue: null }), | ||
funderIdentifier: DS.attr('string', { defaultValue: null }), | ||
funderIdentifierType: DS.attr('string', { defaultValue: 'Other' }), | ||
// schemeUri: DS.attr('string', { defaultValue: null }), | ||
awardNumber: DS.attr('string', { defaultValue: null }), | ||
awardUri: DS.attr('string', { defaultValue: null }), | ||
awardTitle: DS.attr('string', { defaultValue: null }), | ||
}); |
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
Oops, something went wrong.