From 39581a1f7a2753fab8a8868e9cd4ad9fe06e954d Mon Sep 17 00:00:00 2001 From: mbritense <79840403+mbritense@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:17:28 +0100 Subject: [PATCH] fix: save form flow on close task modal (#1295) * fixed last saved by bug * save form flow on close modal --- .../task-detail-content/task-detail-content.component.ts | 4 ++++ .../task-detail-modal/task-detail-modal.component.html | 2 ++ .../task-detail-modal/task-detail-modal.component.ts | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/valtimo/task/src/lib/components/task-detail-content/task-detail-content.component.ts b/projects/valtimo/task/src/lib/components/task-detail-content/task-detail-content.component.ts index 4188be4d9..426aa0f12 100644 --- a/projects/valtimo/task/src/lib/components/task-detail-content/task-detail-content.component.ts +++ b/projects/valtimo/task/src/lib/components/task-detail-content/task-detail-content.component.ts @@ -93,6 +93,10 @@ export class TaskDetailContentComponent implements OnInit, OnDestroy { this.loadTaskDetails(value.task as any, value.processLinkActivityResult); } + @Input() public set modalClosed(_: boolean) { + // save form flow data on modal closed + if (this.formFlow) this.formFlow.saveData(); + } @Output() public readonly closeModalEvent = new EventEmitter(); @Output() public readonly formSubmit = new EventEmitter(); @Output() public readonly activeChange = new EventEmitter(); diff --git a/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.html b/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.html index 02442d9c4..1700be7f2 100644 --- a/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.html +++ b/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.html @@ -66,12 +66,14 @@ @if (processLinkPreloaded$ | async) { } @else { diff --git a/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.ts b/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.ts index c1cbd0f0a..745523ca2 100644 --- a/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.ts +++ b/projects/valtimo/task/src/lib/components/task-detail-modal/task-detail-modal.component.ts @@ -70,6 +70,8 @@ export class TaskDetailModalComponent implements OnInit { public readonly canAssignUserToTask$ = new BehaviorSubject(false); + public readonly modalCloseEvent$ = new BehaviorSubject(false); + private readonly _subscriptions = new Subscription(); constructor( @@ -118,7 +120,7 @@ export class TaskDetailModalComponent implements OnInit { public openTaskAndProcessLinkDetails(taskWithProcessLink: TaskWithProcessLink | null): void { this.processLinkPreloaded$.next(true); this.taskAndProcessLink$.next(taskWithProcessLink); - this.task$.next(taskWithProcessLink.task as any); + this.task$.next({...(taskWithProcessLink.task as any)}); this.page$.next({ title: taskWithProcessLink.task?.name, subtitle: `${this.translateService.instant('taskDetail.taskCreated')} ${taskWithProcessLink.task?.created}`, @@ -147,6 +149,7 @@ export class TaskDetailModalComponent implements OnInit { public closeModal(): void { this._modal.open = false; this.taskIntermediateSaveService.setSubmission({}); + this.modalCloseEvent$.next(!this.modalCloseEvent$.getValue()); } private openModal(): void {