From de887834c6330a05aa1cff6bd7f3bb977b2c678c Mon Sep 17 00:00:00 2001 From: Leashys Date: Tue, 17 Aug 2021 12:22:41 -0400 Subject: [PATCH] Fixes #318 - Improvements to the ability to switch files in Workflow Spec it a) opens a dialogref if you try to switch files without saving changes and b) disincludes (whatever right word is) the file you are on in the menu list --- src/app/modeler/modeler.component.html | 11 ++++-- src/app/modeler/modeler.component.ts | 55 ++++++++++++++++++-------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/src/app/modeler/modeler.component.html b/src/app/modeler/modeler.component.html index 8a598bc..d6c040d 100644 --- a/src/app/modeler/modeler.component.html +++ b/src/app/modeler/modeler.component.html @@ -28,15 +28,20 @@ arrow_drop_down - f.id !== this.fileMetaId); + } + static isXmlFile(file: File) { return file.type.toLowerCase() === 'text/xml' || file.type.toLowerCase() === 'application/xml' || @@ -166,6 +170,25 @@ export class ModelerComponent implements AfterViewInit { } } + checkChangeBPMN(b: FileMeta) { + if (this.hasChanged()) { + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + maxWidth: '300px', + data: { + title: 'Unsaved Changes!', + message: 'Are you sure you want to abandon changes?', + }, + }); + dialogRef.afterClosed().subscribe(dialogResult => { + if (dialogResult) { + this.router.navigate(['/modeler', this.workflowSpecId, b.id]); + } + }); + } else { + this.router.navigate(['/modeler', this.workflowSpecId, b.id]) + } + } + onFileSelected($event: Event) { this.diagramFile = ($event.target as HTMLFormElement).files[0]; this.onSubmitFileToOpen();