From 7f96ad5653b37030687eaa9ad64059840fd9472b Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 11 Aug 2020 16:45:07 -0400 Subject: [PATCH] Makes an arbitrary change to the opened file to enable save button --- src/app/diagram/diagram.component.ts | 17 +++++++++++------ src/app/modeler/modeler.component.ts | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/diagram/diagram.component.ts b/src/app/diagram/diagram.component.ts index 9c79237..fcc4fe0 100644 --- a/src/app/diagram/diagram.component.ts +++ b/src/app/diagram/diagram.component.ts @@ -63,13 +63,13 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { onTouched() { } - initializeModeler(diagramType: FileType) { + initializeModeler(diagramType: FileType): DmnModeler | BpmnModeler { this.clearElements(); if (diagramType === FileType.DMN) { - this.initializeDMNModeler(); + return this.initializeDMNModeler() as DmnModeler; } else { - this.initializeBPMNModeler(); + return this.initializeBPMNModeler() as BpmnModeler; } } @@ -103,7 +103,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { openDiagram(xml?: string, diagramType?: FileType) { this.diagramType = diagramType || getDiagramTypeFromXml(xml); this.xml = xml; - this.initializeModeler(diagramType); + const modeler = this.initializeModeler(diagramType); return this.zone.run(() => { if (!xml) { @@ -111,6 +111,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { xml = defaultXml.replace(/REPLACE_ME/gi, () => this.getRandomString(7)); } + // Add an arbitrary string to get the save button to enable this.modeler.importXML(xml, (e, w) => this.onImport(e, w)); }); } @@ -180,7 +181,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { }); } - private initializeBPMNModeler() { + private initializeBPMNModeler(): BpmnModeler { this.modeler = new BpmnModeler({ container: this.containerRef.nativeElement, propertiesPanel: { @@ -202,9 +203,11 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { }); } }); + + return this.modeler as BpmnModeler; } - private initializeDMNModeler() { + private initializeDMNModeler(): DmnModeler { this.modeler = new DmnModeler({ container: this.containerRef.nativeElement, drd: { @@ -244,6 +247,8 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { }); } }); + + return this.modeler as DmnModeler; } private clearElements() { diff --git a/src/app/modeler/modeler.component.ts b/src/app/modeler/modeler.component.ts index 60b9914..be0fa3c 100644 --- a/src/app/modeler/modeler.component.ts +++ b/src/app/modeler/modeler.component.ts @@ -92,7 +92,7 @@ export class ModelerComponent implements AfterViewInit { this.importError = error; this.importWarnings = warnings; - this.draftXml = this.xml; + this.draftXml = this.xml + ' '; } onSubmitFileToOpen() {