Merge pull request #96 from sartography/chore/change_files_318
Fixes #318 - Improvements to the ability to switch files in Workflow …
This commit is contained in:
commit
59c080e0f9
|
@ -28,15 +28,20 @@
|
|||
<mat-icon>arrow_drop_down</mat-icon>
|
||||
</button>
|
||||
<mat-menu #importMenu="matMenu">
|
||||
<button mat-menu-item (click)="openMethod = 'db'" [matMenuTriggerFor]="dbMenu" title="Open diagram from database">
|
||||
<button
|
||||
mat-menu-item
|
||||
[disabled]="bpmnFilesNoSelf.length === 0"
|
||||
(click)="openMethod = 'db'"
|
||||
[matMenuTriggerFor]="dbMenu"
|
||||
title="Open diagram from database">
|
||||
<mat-icon>cloud</mat-icon>
|
||||
Open related BPMN/DMN File ...
|
||||
</button>
|
||||
<mat-menu #dbMenu="matMenu">
|
||||
<a
|
||||
mat-menu-item
|
||||
*ngFor="let bf of bpmnFiles"
|
||||
[routerLink]="['/modeler', workflowSpec.id, bf.id]"
|
||||
*ngFor="let bf of bpmnFilesNoSelf"
|
||||
(click)="checkChangeBPMN(bf)"
|
||||
[matTooltip]="getFileMetaTooltipText(bf)"
|
||||
matTooltipClass="tooltip-text"
|
||||
matTooltipPosition="right"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { DatePipe } from '@angular/common';
|
||||
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
|
||||
import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import {DatePipe} from '@angular/common';
|
||||
import {AfterViewInit, Component, ElementRef, ViewChild} from '@angular/core';
|
||||
import {MatBottomSheet} from '@angular/material/bottom-sheet';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||
import {ActivatedRoute, Params, Router} from '@angular/router';
|
||||
import {
|
||||
ApiErrorsComponent,
|
||||
ApiService,
|
||||
|
@ -13,15 +13,15 @@ import {
|
|||
newFileFromResponse,
|
||||
WorkflowSpec,
|
||||
} from 'sartography-workflow-lib';
|
||||
import { FileMetaDialogComponent } from '../_dialogs/file-meta-dialog/file-meta-dialog.component';
|
||||
import { NewFileDialogComponent } from '../_dialogs/new-file-dialog/new-file-dialog.component';
|
||||
import { ConfirmDialogComponent } from '../_dialogs/confirm-dialog/confirm-dialog.component';
|
||||
import { BpmnWarning } from '../_interfaces/bpmn-warning';
|
||||
import { FileMetaDialogData, NewFileDialogData } from '../_interfaces/dialog-data';
|
||||
import { ImportEvent } from '../_interfaces/import-event';
|
||||
import { DiagramComponent } from '../diagram/diagram.component';
|
||||
import { SettingsService } from '../settings.service';
|
||||
import { getDiagramTypeFromXml } from '../_util/diagram-type';
|
||||
import {FileMetaDialogComponent} from '../_dialogs/file-meta-dialog/file-meta-dialog.component';
|
||||
import {NewFileDialogComponent} from '../_dialogs/new-file-dialog/new-file-dialog.component';
|
||||
import {ConfirmDialogComponent} from '../_dialogs/confirm-dialog/confirm-dialog.component';
|
||||
import {BpmnWarning} from '../_interfaces/bpmn-warning';
|
||||
import {FileMetaDialogData, NewFileDialogData} from '../_interfaces/dialog-data';
|
||||
import {ImportEvent} from '../_interfaces/import-event';
|
||||
import {DiagramComponent} from '../diagram/diagram.component';
|
||||
import {SettingsService} from '../settings.service';
|
||||
import {getDiagramTypeFromXml} from '../_util/diagram-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-modeler',
|
||||
|
@ -30,7 +30,6 @@ import { getDiagramTypeFromXml } from '../_util/diagram-type';
|
|||
})
|
||||
export class ModelerComponent implements AfterViewInit {
|
||||
@ViewChild('fileInput', {static: true}) fileInput: ElementRef;
|
||||
@ViewChild(DiagramComponent) private diagramComponent: DiagramComponent;
|
||||
title = 'bpmn-js-angular';
|
||||
diagramUrl = 'https://cdn.staticaly.com/gh/bpmn-io/bpmn-js-examples/dfceecba/starter/diagram.bpmn';
|
||||
importError?: Error;
|
||||
|
@ -45,6 +44,7 @@ export class ModelerComponent implements AfterViewInit {
|
|||
fileTypes = FileType;
|
||||
validationState: string;
|
||||
validationData: { [key: string]: any } = {};
|
||||
@ViewChild(DiagramComponent) private diagramComponent: DiagramComponent;
|
||||
private xml = '';
|
||||
private draftXml = '';
|
||||
private svg = '';
|
||||
|
@ -74,6 +74,10 @@ export class ModelerComponent implements AfterViewInit {
|
|||
});
|
||||
}
|
||||
|
||||
get bpmnFilesNoSelf(): FileMeta[] {
|
||||
return this.bpmnFiles.filter(f => 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();
|
||||
|
|
Loading…
Reference in New Issue