Enables save button when decision table is altered

This commit is contained in:
Aaron Louie 2020-05-23 14:46:32 -04:00
parent 91132ff792
commit 0aab80522a
2 changed files with 17 additions and 5 deletions

View File

@ -57,6 +57,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit {
}
onChange(newValue: string, svgValue: string) {
console.log('DiagramComponent default onChange');
}
onTouched() {
@ -123,6 +124,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit {
}
saveDiagram() {
if (this.modeler && this.modeler.saveSVG) {
this.modeler.saveSVG((svgErr, svg) => {
this.svg = svg;
this.modeler.saveXML({format: true}, (xmlErr, xml) => {
@ -130,6 +132,12 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit {
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}) => {

View File

@ -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;
});