From a9a7e6edd397ed418f35345acaa910839a7b99c3 Mon Sep 17 00:00:00 2001 From: Fuzi_fauzia Date: Thu, 22 Aug 2024 10:42:01 +0700 Subject: [PATCH] warning perubahan data pada list monitoring --- .../add-edit-list/add-edit-list.component.ts | 20 ++++++++++++++++++- .../modal-export/modal-export.component.html | 12 +++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.ts b/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.ts index 971b365..d225ff5 100644 --- a/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.ts +++ b/src/app/content/hemat-app/list-monitoring/add-edit-list/add-edit-list.component.ts @@ -15,6 +15,7 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; import { AddEditMasterBuildingComponent } from "../../master/master-building/add-edit-master-building/add-edit-master-building.component"; import { AddEditMasterComponent } from "../../master/add-edit-master/add-edit-master.component"; import { AddEditMasterRoomComponent } from "../../master/master-room/add-edit-master-room/add-edit-master-room.component"; +import Swal from "sweetalert2"; @Component({ selector: "app-add-edit-list", @@ -337,7 +338,24 @@ export class AddEditListComponent { } cancel() { - this.router.navigate(["/list-monitoring"]); + if (this.projectInfo.dirty) { // Check if form has unsaved changes + Swal.fire({ + title: 'Are you sure?', + text: "You have unsaved changes. Do you really want to leave?", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, leave', + cancelButtonText: 'No, stay' + }).then((result) => { + if (result.isConfirmed) { + this.router.navigate(["/list-monitoring"]); + } + }); + } else { + this.router.navigate(["/list-monitoring"]); + } } modalAddBuilding() { diff --git a/src/app/content/hemat-app/monitoring/modal-export/modal-export.component.html b/src/app/content/hemat-app/monitoring/modal-export/modal-export.component.html index 783a8a3..c4597fa 100644 --- a/src/app/content/hemat-app/monitoring/modal-export/modal-export.component.html +++ b/src/app/content/hemat-app/monitoring/modal-export/modal-export.component.html @@ -126,7 +126,7 @@