Added Line HighLighting

This commit is contained in:
NWalker4483 2021-07-19 16:48:42 -04:00
parent 9307c32d0d
commit 6c1741a5e3
4 changed files with 33 additions and 18 deletions

View File

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

View File

@ -27,10 +27,11 @@ import { dmnModelerConfig } from './dmn-modeler-config';
export class DiagramComponent implements ControlValueAccessor, AfterViewInit, OnChanges { export class DiagramComponent implements ControlValueAccessor, AfterViewInit, OnChanges {
@Input() fileName: string; @Input() fileName: string;
@Input() validation_data: Object = {}; @Input() validation_data: Object = {};
@Input() validation_state: string;
@ViewChild('containerRef', { static: true }) containerRef: ElementRef; @ViewChild('containerRef', { static: true }) containerRef: ElementRef;
@ViewChild('propertiesRef', { static: true }) propertiesRef: ElementRef; @ViewChild('propertiesRef', { static: true }) propertiesRef: ElementRef;
@Output() private importDone: EventEmitter<ImportEvent> = new EventEmitter(); @Output() private importDone: EventEmitter<ImportEvent> = new EventEmitter();
@Input() validationState: string;
@Output() validationStart: EventEmitter<string> = new EventEmitter(); @Output() validationStart: EventEmitter<string> = new EventEmitter();
private diagramType: FileType; private diagramType: FileType;
private modeler: BpmnModeler | DmnModeler; private modeler: BpmnModeler | DmnModeler;
@ -69,7 +70,20 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On
if (changes.validation_data) { if (changes.validation_data) {
this.validation_data = changes.validation_data.currentValue; this.validation_data = changes.validation_data.currentValue;
if (this.modeler) { if (this.modeler) {
this.modeler.get('eventBus').fire('editor.objects.response', { objects: this.validation_data }); if(this.validation_data['task_data']) {
this.modeler.get('eventBus').fire('editor.objects.response', {objects: this.validation_data['task_data']});
}
}
}
if (changes.validation_state) {
this.validation_state = changes.validation_state.currentValue;
if (this.modeler) {
const resp = {state: this.validation_state, line_number: undefined
};
if (this.validation_data['line_number']){
resp.line_number = this.validation_data['line_number'];
}
this.modeler.get('eventBus').fire('editor.validation.response', resp);
} }
} }
} }
@ -226,7 +240,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On
}); });
}); });
eventBus.on('editor.validate.request', (request) => { eventBus.on('editor.validation.request', (request) => {
this.validationStart.emit(request.task_name); this.validationStart.emit(request.task_name);
}); });

View File

@ -72,7 +72,7 @@
<div fxLayout="column"> <div fxLayout="column">
<div class="diagram-parent"> <div class="diagram-parent">
<app-diagram #diagram (importDone)="handleImported($event)" [fileName]="getFileName()" [validation_data]="validationData" (validationStart)="partially_validate($event)" ></app-diagram> <app-diagram #diagram (importDone)="handleImported($event)" [fileName]="getFileName()" [validation_state]="validationState" [validation_data]="validationData" (validationStart)="partially_validate($event)" ></app-diagram>
<div *ngIf="importError" class="import-error"> <div *ngIf="importError" class="import-error">
<strong>Failed to render diagram: </strong> <strong>Failed to render diagram: </strong>

View File

@ -68,7 +68,7 @@ export class ModelerComponent implements AfterViewInit {
@ViewChild(DiagramComponent) private diagramComponent: DiagramComponent; @ViewChild(DiagramComponent) private diagramComponent: DiagramComponent;
@ViewChild('fileInput', { static: true }) fileInput: ElementRef; @ViewChild('fileInput', { static: true }) fileInput: ElementRef;
private diagramType: FileType; private diagramType: FileType;
private validationState: boolean; private validationState: string;
validationData: Object = {}; validationData: Object = {};
private workflowSpecId: string; private workflowSpecId: string;
private fileMetaId: number; private fileMetaId: number;
@ -202,19 +202,20 @@ export class ModelerComponent implements AfterViewInit {
partially_validate(until_task: string) { partially_validate(until_task: string) {
this.saveChanges(); this.saveChanges();
const study_id = this.settingsService.getStudyIdForValidation(); const study_id = this.settingsService.getStudyIdForValidation();
this.api.validateWorkflowSpecification(this.diagramFileMeta.workflow_spec_id, until_task, study_id).subscribe(apiErrors => { this.validationState = 'unknown';
this.validationState = true; this.validationData = { 'testing_only': {a: 1, b: 'b', c: false, e: [], d: undefined}, 'real_fields': undefined };
this.validationData = { 'required_only': undefined, 'all_fields': undefined };
if (apiErrors && apiErrors.length === 2) {
if (apiErrors[0].code === 'validation_break') {
this.validationData['all_fields'] = apiErrors[0].task_data;
} else { this.validationState = false; }
if (apiErrors[1].code === 'validation_break') {
this.validationData['required_only'] = apiErrors[1].task_data;
} else { this.validationState = false; }
} else { this.validationState = false; }
if (this.validationState === false) { this.api.validateWorkflowSpecification(this.diagramFileMeta.workflow_spec_id, until_task, study_id).subscribe(apiErrors => {
if (apiErrors && apiErrors.length === 1) {
if (apiErrors[0].code === 'validation_break') {
this.validationData = apiErrors[0];
this.validationState = 'passing';
} else {
this.validationData = apiErrors[0];
this.validationState = 'failing';
}
}
if (apiErrors.length > 0 && this.validationState !== 'passing') {
this.bottomSheet.open(ApiErrorsComponent, { data: { apiErrors: apiErrors } }); this.bottomSheet.open(ApiErrorsComponent, { data: { apiErrors: apiErrors } });
} }
}); });