From 85b1fc7a9a7aa7d4b09837b151283d1d11aab588 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Wed, 9 Feb 2022 11:41:23 +0200 Subject: [PATCH] update dynamically the stakeholders' alias list on create, edit, delete --- .../manageStakeholders/manageStakeholders.component.ts | 10 +++++++++- src/app/openaireLibrary | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/manageStakeholders/manageStakeholders.component.ts b/src/app/manageStakeholders/manageStakeholders.component.ts index 692d175..d2d6fa8 100644 --- a/src/app/manageStakeholders/manageStakeholders.component.ts +++ b/src/app/manageStakeholders/manageStakeholders.component.ts @@ -195,11 +195,17 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy { this.editStakeholderComponent.init(this.stakeholder, this.alias, this.defaultStakeholders, isDefault, this.index === -1); if (this.index !== -1) { this.callback = (stakeholder: Stakeholder) => { + let index = -1; if (stakeholder.defaultId == null) { + index = this.alias.findIndex(value => value == this.defaultStakeholders[this.index].alias); this.defaultStakeholders[this.index] = stakeholder; } else { + index = this.alias.findIndex(value => value == this.stakeholders[this.index].alias); this.stakeholders[this.index] = stakeholder; } + if(index != -1) { + this.alias[index] = stakeholder.alias; + } }; this.editStakeholderModal.okButtonText = 'Save Changes'; } else { @@ -207,8 +213,9 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy { if (stakeholder.defaultId === null) { this.defaultStakeholders.push(stakeholder); } else { - this.stakeholders.push(stakeholder); + this.stakeholders.push(stakeholder); } + this.alias.push(stakeholder.alias); }; this.editStakeholderModal.okButtonText = 'Create'; } @@ -239,6 +246,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy { timeout: 6000, pos: 'bottom-right' }); + this.alias = this.alias.filter(item => item !== this.stakeholder.alias); if (!this.stakeholder.defaultId) { this.defaultStakeholders.splice(this.index, 1); } else { diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 0561d94..965b1ee 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 0561d945c55068dc9297f83cf7caff1eb7b0b97b +Subproject commit 965b1ee134bc56313b5912e83a2ae23387e4c493