This commit is contained in:
NWalker4483 2021-06-09 14:55:05 -04:00
parent 4114554b61
commit 25927f070f
4 changed files with 84 additions and 35 deletions

6
package-lock.json generated
View File

@ -5527,9 +5527,9 @@
}
},
"diagram-js-code-editor": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/diagram-js-code-editor/-/diagram-js-code-editor-1.0.4.tgz",
"integrity": "sha512-Mez70gLxG+XYQ+mVd2D88qH/tgXqFwsiCS0hncOc+B02X6HVNJtn10GyLsr5418+O/1Sal0pEgFitQCZoiTceA==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/diagram-js-code-editor/-/diagram-js-code-editor-1.0.6.tgz",
"integrity": "sha512-4sCboTOtnUkh7lgGoqOt6aE/ENmJKpUYc1oLDFu6BWIPHPIxPwXgll98sTsZHfXEZGIQq9vfD68yvV+eGAeybg==",
"requires": {
"ace": "^1.3.0",
"ace-builds": "^1.4.12",

View File

@ -42,7 +42,7 @@
"camunda-bpmn-moddle": "^4.4.0",
"camunda-dmn-moddle": "^1.0.0",
"diagram-js": "^6.6.1",
"diagram-js-code-editor": "^1.0.4",
"diagram-js-code-editor": "^1.0.6",
"diagram-js-minimap": "^2.0.3",
"dmn-js": "^7.5.1",
"dmn-js-properties-panel": "^0.3.5",

View File

@ -29,10 +29,11 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit {
@ViewChild('propertiesRef', {static: true}) propertiesRef: ElementRef;
@Output() private importDone: EventEmitter<ImportEvent> = new EventEmitter();
private diagramType: FileType;
private modeler: BpmnModeler | DmnModeler;
public modeler: BpmnModeler | DmnModeler;
private xml = '';
private svg;
private disabled = false;
public eventBus;
// Hack so we can spy on this function
private _formatDate = formatDate;
@ -204,9 +205,25 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit {
}
});
this.eventBus = this.modeler.get('eventBus');
this.eventBus.on('editor.scripts.request', () => {
this.api.listScripts().subscribe((data) => {
this.modeler.get('eventBus').fire('editor.scripts.response', { scripts: data });
})
});
// this.modeler.get('eventBus').on('editor.objects.request', () => {
// let data = [{userId: "int", description: "string"}]
// this.modeler.get('eventBus').fire('editor.scripts.response', {objects: data});
// });
return this.modeler as BpmnModeler;
}
private validate(){
}
private initializeDMNModeler(): DmnModeler {
this.modeler = new DmnModeler({
container: this.containerRef.nativeElement,

View File

@ -89,10 +89,41 @@ export class ModelerComponent implements AfterViewInit {
}
this.svg = newSvgValue;
});
this.diagramComponent.modeler.get('eventBus').on('editor.validate.request', (request) => {
this.saveChanges();
console.log("Validating...", request.code);
this.api.validateWorkflowSpecification(this.diagramFileMeta.workflow_spec_id).subscribe(apiErrors => {
// apiErrors =
console.log(33);
if (apiErrors && apiErrors.length > 0) {
let passing = true;
let data = {};
apiErrors.forEach((error) => {
if (error.code == "validation_break") {
data = error.task_data;
}
else
{
passing = false;
}
});
this.diagramComponent.eventBus.fire('editor.validate.response', { passing: true, msg: "msg", data: data});
// this.bottomSheet.open(ApiErrorsComponent, { data: { apiErrors: apiErrors } });
} else {
// this.snackBar.open('Workflow specification is valid!', 'Ok', { duration: 5000 });
}
});
});
if (this.requestFileClick) {
this.fileInput.nativeElement.click();
this.requestFileClick = false;
}
}
handleImported(event: ImportEvent) {
@ -155,7 +186,8 @@ export class ModelerComponent implements AfterViewInit {
dialogRef.afterClosed().subscribe(dialogResult => {
if (dialogResult) {
this.router.navigate(['/home', this.workflowSpec.name]);
}});
}
});
} else {
this.router.navigate(['/home', this.workflowSpec.name]);
}