From 62002f94ef38a471bc78f2f657777051a2b0ab87 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Fri, 3 Apr 2020 10:23:55 +0200 Subject: [PATCH] only use name variant after modal closes --- ...-search-result-list-submission-element.component.ts | 9 ++++++--- ...-search-result-list-submission-element.component.ts | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.ts index 96f28a799b..d94bf4fd51 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.ts +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.ts @@ -75,7 +75,7 @@ export class OrgUnitSearchResultListSubmissionElementComponent extends SearchRes if (!this.allSuggestions.includes(value)) { this.openModal(value) .then(() => { - + // user clicked ok: store the name variant in the item const newName: MetadataValue = new MetadataValue(); newName.value = value; @@ -89,9 +89,12 @@ export class OrgUnitSearchResultListSubmissionElementComponent extends SearchRes }, }); this.itemDataService.update(updatedItem).pipe(take(1)).subscribe(); - }) + }).catch(() => { + // user clicked cancel: use the name variant only for this relation, no further action required + }).finally(() => { + this.select(value); + }) } - this.select(value); } openModal(value): Promise { diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts index 08838c3223..42f8d72c70 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.ts @@ -75,7 +75,7 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu if (!this.allSuggestions.includes(value)) { this.openModal(value) .then(() => { - + // user clicked ok: store the name variant in the item const newName: MetadataValue = new MetadataValue(); newName.value = value; @@ -89,12 +89,12 @@ export class PersonSearchResultListSubmissionElementComponent extends SearchResu }, }); this.itemDataService.update(updatedItem).pipe(take(1)).subscribe(); - } - ).catch(() => { - /* empty, don't throw console error */ + }).catch(() => { + // user clicked cancel: use the name variant only for this relation, no further action required + }).finally(() => { + this.select(value); }) } - this.select(value); } openModal(value): Promise {