From a69ff7ff308acda729876de0bb74b2bf081d7a7b Mon Sep 17 00:00:00 2001 From: Fabian Vogler Date: Fri, 30 Aug 2024 18:20:15 +0200 Subject: [PATCH] Update DelegateType in line --- .../delegate-types.component.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/delegate-types/delegate-types.component.ts b/src/app/delegate-types/delegate-types.component.ts index 7e9754d..c0b2df2 100644 --- a/src/app/delegate-types/delegate-types.component.ts +++ b/src/app/delegate-types/delegate-types.component.ts @@ -66,11 +66,20 @@ export class DelegateTypesComponent extends WsComponent implements OnInit { } save(dt: DelegateType): void { - (dt.id === 0 ? this.delTypeService.create(this.selectedEvent.id, dt) : this.delTypeService.update(this.selectedEvent.id, dt)).subscribe(res => { - this.loadData(); - this.manageDelType = null; - this.toastService.success('Delegate Type is saved!'); - }); + if (dt.id === 0) { + this.delTypeService.create(this.selectedEvent.id, dt).subscribe(res => { + this.loadData(); + this.manageDelType = null; + this.toastService.success('Delegate Type is saved!'); + }); + } else { + this.delTypeService.update(this.selectedEvent.id, dt).subscribe(res => { + const index = this.delegateTypes.findIndex(d => d.id === dt.id); + this.delegateTypes[index] = dt; + this.manageDelType = null; + this.toastService.success('Delegate Type is saved!'); + }); + } } deleteDelType(dt: DelegateType): void {