From a22f6176f2d680a7f8cdf5102c2ad4d1191b4e7f Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 26 Nov 2019 23:12:34 +0100 Subject: [PATCH] handle remove affiliation #246 --- app/components/doi-affiliation.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/components/doi-affiliation.js b/app/components/doi-affiliation.js index ea66d2fb8..678f83598 100644 --- a/app/components/doi-affiliation.js +++ b/app/components/doi-affiliation.js @@ -7,12 +7,21 @@ export default Component.extend({ organizations: [], updateAffiliation(organizationRecord) { - this.fragment.set('name', organizationRecord.name); - this.fragment.set('affiliationIdentifier', organizationRecord.id); - this.fragment.set('schemeUri', 'https://ror.org'); - this.fragment.set('affiliationIdentifierScheme', 'ROR'); - - this.setCreatorValidationClass(); + if (organizationRecord) { + this.fragment.set('name', organizationRecord.name); + this.fragment.set('affiliationIdentifier', organizationRecord.id); + this.fragment.set('schemeUri', 'https://ror.org'); + this.fragment.set('affiliationIdentifierScheme', 'ROR'); + + this.setCreatorValidationClass(); + } else { + this.fragment.set('name', null); + this.fragment.set('affiliationIdentifier', null); + this.fragment.set('schemeUri', 'https://ror.org'); + this.fragment.set('affiliationIdentifierScheme', 'ROR'); + + // this.setCreatorValidationClass(); + } }, actions: { @@ -23,11 +32,7 @@ export default Component.extend({ }); }, selectRor(ror) { - if (ror) { - this.updateAffiliation(ror); - } else { - this.updateAffiliation(null); - } + this.updateAffiliation(ror); }, deleteAffiliation() { this.creator.get('affiliation').removeObject(this.fragment);