From 763fffbaa054f10f9af4d88e1b6c660380da6d8d Mon Sep 17 00:00:00 2001 From: Kelly McDonald Date: Mon, 25 Jan 2021 09:58:19 -0500 Subject: [PATCH] Added warning when the back arrow is hit but the file is not saved. I would like to use a better looking confirm box if available. --- src/app/modeler/modeler.component.html | 2 +- src/app/modeler/modeler.component.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/modeler/modeler.component.html b/src/app/modeler/modeler.component.html index 33d5d7f..cf3dfc1 100644 --- a/src/app/modeler/modeler.component.html +++ b/src/app/modeler/modeler.component.html @@ -1,6 +1,6 @@ - + arrow_back Back diff --git a/src/app/modeler/modeler.component.ts b/src/app/modeler/modeler.component.ts index e6e3f65..36b2d34 100644 --- a/src/app/modeler/modeler.component.ts +++ b/src/app/modeler/modeler.component.ts @@ -125,10 +125,19 @@ export class ModelerComponent implements AfterViewInit { getFileName() { return this.diagramFile ? this.diagramFile.name : this.fileName || 'No file selected'; } - + checkSaved(){ + if (this.hasChanged()) { + const approve = window.confirm('Unsaved Changes - Are you sure?'); + if (approve) { + this.router.navigate(['/home', this.workflowSpec.name]); + } + } else { + this.router.navigate(['/home', this.workflowSpec.name]); + } + } onFileSelected($event: Event) { this.diagramFile = ($event.target as HTMLFormElement).files[0]; - this.onSubmitFileToOpen() + this.onSubmitFileToOpen(); this.isNew = true; }