Commit d8d478cc authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add remove process patterns

parent ffbbb55a
......@@ -40,6 +40,23 @@
</div>
</ng-template>
<ng-template #deleteProcessPatternModal let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Delete Process Pattern {{modalElement.businessObject.name}}</h4>
<button type="button" class="close" aria-label="Close" (click)="d()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-warning">Deleting the process pattern {{modalElement.businessObject.name}}.</div>
</div>
<div class="modal-footer">
<button class="btn btn-danger btn-block" (click)="deleteProcessPattern(modalElement); d()">
Delete Process Pattern
</button>
</div>
</ng-template>
<div #canvas class="border" style="height: 500px"></div>
<div class="container">
<div class="my-3 p-3 bg-white rounded shadow-sm">
......
......@@ -24,6 +24,7 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
@ViewChild('canvas', {static: true}) canvas: ElementRef<HTMLDivElement>;
@ViewChild('addProcessPatternModal', {static: true}) addProcessPatternModal: any;
@ViewChild('deleteProcessPatternModal', {static: true}) deleteProcessPatternModal: any;
@ViewChild('showCategoriesModal', {static: true}) showCategoriesModal: any;
constructor(
......@@ -36,6 +37,7 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
ngOnInit() {
this.modeler = this.bpmnService.getBmProcessModeler();
const eventBus = this.modeler.get('eventBus');
eventBus.on('bmdl.deletePattern', (event, subProcessElement) => this.openDeleteProcessPatternModal(subProcessElement));
eventBus.on('bmdl.processPatterns', (event, businessObject) => this.openAddProcessPatternModal(businessObject));
eventBus.on('bmdl.showCategories', (event, taskElement) => this.openShowCategoriesModal(taskElement));
if (this.bmProcess) {
......@@ -86,6 +88,15 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
this.modalReference = this.modalService.open(this.showCategoriesModal, {size: 'lg'});
}
openDeleteProcessPatternModal(subProcessElement) {
this.modalElement = subProcessElement;
this.modalReference = this.modalService.open(this.deleteProcessPatternModal, {size: 'lg'});
}
deleteProcessPattern(subProcessElement) {
this.bpmnService.removeProcessPattern(this.modeler, subProcessElement);
}
save() {
this.modeler.saveXML().then(result => this.saveBmProcess.emit(result.xml));
}
......
......@@ -12,31 +12,38 @@ export default class BmProcessContextPadProvider {
}
getContextPadEntries(element) {
const controls = {};
if (is(element, 'bpmn:SubProcess')) {
controls['bmdl.deletePattern'] = {
group: 'edit',
className: 'bpmn-icon-trash',
title: 'Delete Process Pattern',
action: {
click: () => this.eventBus.fire('bmdl.deletePattern', element),
}
};
}
if ((is(element, 'bpmn:StartEvent') || is(element, 'bpmn:SubProcess')) && element.businessObject.get('outgoing').length === 0) {
return {
'bmdl.processPatterns': {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Add Process Pattern',
action: {
click: () => this.eventBus.fire('bmdl.processPatterns', element),
}
controls['bmdl.processPatterns'] = {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Add Process Pattern',
action: {
click: () => this.eventBus.fire('bmdl.processPatterns', element),
}
};
} else if (is(element, 'bpmn:Task')) {
return {
'bpmn.showCategories': {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Show categories',
action: {
click: () => this.eventBus.fire('bmdl.showCategories', element),
}
}
if (is(element, 'bpmn:Task')) {
controls['bpmn.showCategories'] = {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Show categories',
action: {
click: () => this.eventBus.fire('bmdl.showCategories', element),
}
};
} else {
return {};
}
return controls;
}
}
......@@ -50,6 +50,17 @@ export class BpmnService {
new AppendBpmnOperation(current, append).append(lastElement, processName);
}
/**
* Removes a process pattern from the modeler
*
* @param modeler the modeler
* @param subProcessElement the sub process representing the process pattern
*/
removeProcessPattern(modeler: BpmnModeler, subProcessElement) {
const modeling = modeler.get('modeling');
modeling.removeElements([subProcessElement]);
}
}
class AppendBpmnOperation {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment