From 698b0d97e5c60920c7ae99473dfa7baacf07f2a0 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 5 Dec 2021 19:28:59 -0700 Subject: [PATCH] closes #910 --- .../form-object/form-object.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ui/src/app/components/form-object/form-object.component.ts b/ui/src/app/components/form-object/form-object.component.ts index 917fd8af9..2dae520d5 100644 --- a/ui/src/app/components/form-object/form-object.component.ts +++ b/ui/src/app/components/form-object/form-object.component.ts @@ -162,7 +162,7 @@ export class FormObjectComponent { component: EnumListPage, }) - modal.onWillDismiss().then(res => { + modal.onWillDismiss().then((res: { data: string[] }) => { const data = res.data if (!data) return this.updateEnumList(key, current, data) @@ -228,7 +228,7 @@ export class FormObjectComponent { if (this.objectListDisplay[key]) this.objectListDisplay[key][index].height = '0px' const arr = this.formGroup.get(key) as FormArray if (markDirty) arr.markAsDirty() - pauseFor(500).then(() => { + pauseFor(250).then(() => { if (this.objectListDisplay[key]) this.objectListDisplay[key].splice(index, 1) arr.removeAt(index) }) @@ -237,11 +237,17 @@ export class FormObjectComponent { private updateEnumList (key: string, current: string[], updated: string[]) { this.formGroup.get(key).markAsDirty() - let deleted = current.filter(x => !updated.includes(x)) - deleted.forEach((_, index) => this.deleteListItem(key, index, false)) + current.forEach((val, index) => { + if (!updated.includes(val)) { + this.deleteListItem(key, index, false) + } + }) - let added = updated.filter(x => !current.includes(x)) - added.forEach(val => this.addListItem(key, false, val)) + updated.forEach(val => { + if (!current.includes(val)) { + this.addListItem(key, false, val) + } + }) } private getDocSize (selected: string) {