From 0aab80522a24306428f4202d7255feadde449472 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sat, 23 May 2020 14:46:32 -0400 Subject: [PATCH] Enables save button when decision table is altered --- src/app/diagram/diagram.component.ts | 21 ++++++++++++++++----- src/app/modeler/modeler.component.ts | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/app/diagram/diagram.component.ts b/src/app/diagram/diagram.component.ts index db402f2..9c79237 100644 --- a/src/app/diagram/diagram.component.ts +++ b/src/app/diagram/diagram.component.ts @@ -57,6 +57,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { } onChange(newValue: string, svgValue: string) { + console.log('DiagramComponent default onChange'); } onTouched() { @@ -123,13 +124,20 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { } saveDiagram() { - this.modeler.saveSVG((svgErr, svg) => { - this.svg = svg; + if (this.modeler && this.modeler.saveSVG) { + this.modeler.saveSVG((svgErr, svg) => { + this.svg = svg; + this.modeler.saveXML({format: true}, (xmlErr, xml) => { + this.xml = xml; + this.writeValue(xml); + }); + }); + } else { this.modeler.saveXML({format: true}, (xmlErr, xml) => { this.xml = xml; this.writeValue(xml); }); - }); + } } saveXML() { @@ -208,14 +216,17 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit { moddleExtensions: dmnModelerConfig.moddleExtensions, }); - this.modeler.on('commandStack.changed', () => this.saveDiagram()); + this.modeler.on('commandStack.changed', () => { + this.saveDiagram(); + }); this.modeler.on('views.changed', () => { + this.saveDiagram(); + const viewer = this.modeler.getActiveViewer(); if (viewer) { viewer.get('eventBus').on('commandStack.changed', () => this.saveDiagram()); } - this.saveDiagram(); }); this.modeler.on('import.done', ({error}) => { diff --git a/src/app/modeler/modeler.component.ts b/src/app/modeler/modeler.component.ts index b8a3807..6d53c8a 100644 --- a/src/app/modeler/modeler.component.ts +++ b/src/app/modeler/modeler.component.ts @@ -69,6 +69,7 @@ export class ModelerComponent implements AfterViewInit { ngAfterViewInit(): void { this.diagramComponent.registerOnChange((newXmlValue: string, newSvgValue: string) => { + console.log('ModelerComponent > DiagramComponent > onChange'); this.draftXml = newXmlValue; this.svg = newSvgValue; });