This commit is contained in:
Matt Hill
2021-12-05 19:28:59 -07:00
committed by Aiden McClelland
parent 26c8b6c647
commit 698b0d97e5

View File

@@ -162,7 +162,7 @@ export class FormObjectComponent {
component: EnumListPage, component: EnumListPage,
}) })
modal.onWillDismiss().then(res => { modal.onWillDismiss().then((res: { data: string[] }) => {
const data = res.data const data = res.data
if (!data) return if (!data) return
this.updateEnumList(key, current, data) this.updateEnumList(key, current, data)
@@ -228,7 +228,7 @@ export class FormObjectComponent {
if (this.objectListDisplay[key]) this.objectListDisplay[key][index].height = '0px' if (this.objectListDisplay[key]) this.objectListDisplay[key][index].height = '0px'
const arr = this.formGroup.get(key) as FormArray const arr = this.formGroup.get(key) as FormArray
if (markDirty) arr.markAsDirty() if (markDirty) arr.markAsDirty()
pauseFor(500).then(() => { pauseFor(250).then(() => {
if (this.objectListDisplay[key]) this.objectListDisplay[key].splice(index, 1) if (this.objectListDisplay[key]) this.objectListDisplay[key].splice(index, 1)
arr.removeAt(index) arr.removeAt(index)
}) })
@@ -237,11 +237,17 @@ export class FormObjectComponent {
private updateEnumList (key: string, current: string[], updated: string[]) { private updateEnumList (key: string, current: string[], updated: string[]) {
this.formGroup.get(key).markAsDirty() this.formGroup.get(key).markAsDirty()
let deleted = current.filter(x => !updated.includes(x)) current.forEach((val, index) => {
deleted.forEach((_, index) => this.deleteListItem(key, index, false)) if (!updated.includes(val)) {
this.deleteListItem(key, index, false)
}
})
let added = updated.filter(x => !current.includes(x)) updated.forEach(val => {
added.forEach(val => this.addListItem(key, false, val)) if (!current.includes(val)) {
this.addListItem(key, false, val)
}
})
} }
private getDocSize (selected: string) { private getDocSize (selected: string) {