feat(modeling): delete nested subprocesses
This commit is contained in:
parent
2e672d0e24
commit
d3ecd92dcd
|
@ -95,6 +95,41 @@ export default function SubProcessPlaneBehavior(
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
|
||||||
|
this.preExecuted('shape.delete', function(context) {
|
||||||
|
var shape = context.shape;
|
||||||
|
if (!isCollapsedSubProcess(shape)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var attachedRoot = elementRegistry.get(planeId(shape));
|
||||||
|
|
||||||
|
if (!attachedRoot) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modeling.removeElements(attachedRoot.children.slice());
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
|
||||||
|
this.executed('shape.delete', function(context) {
|
||||||
|
var shape = context.shape;
|
||||||
|
if (!isCollapsedSubProcess(shape)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
removeRoot(context);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
|
||||||
|
this.reverted('shape.delete', function(context) {
|
||||||
|
var shape = context.shape;
|
||||||
|
if (!isCollapsedSubProcess(shape)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createRoot(context);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
|
||||||
this.preExecuted('shape.replace', function(context) {
|
this.preExecuted('shape.replace', function(context) {
|
||||||
var oldShape = context.oldShape;
|
var oldShape = context.oldShape;
|
||||||
var newShape = context.newShape;
|
var newShape = context.newShape;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
</bpmn:subProcess>
|
</bpmn:subProcess>
|
||||||
<bpmn:sequenceFlow id="Flow_1d6ajf7" sourceRef="inlineSubprocess_2" targetRef="Event_1ic2bhx" />
|
<bpmn:sequenceFlow id="Flow_1d6ajf7" sourceRef="inlineSubprocess_2" targetRef="Event_1ic2bhx" />
|
||||||
</bpmn:subProcess>
|
</bpmn:subProcess>
|
||||||
|
<bpmn:subProcess id="emptyProcess" />
|
||||||
</bpmn:process>
|
</bpmn:process>
|
||||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0vkcvif">
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0vkcvif">
|
||||||
|
@ -37,14 +38,17 @@
|
||||||
<bpmndi:BPMNShape id="Event_0lrpy3a_di" bpmnElement="Event_0lrpy3a">
|
<bpmndi:BPMNShape id="Event_0lrpy3a_di" bpmnElement="Event_0lrpy3a">
|
||||||
<dc:Bounds x="272" y="222" width="36" height="36" />
|
<dc:Bounds x="272" y="222" width="36" height="36" />
|
||||||
</bpmndi:BPMNShape>
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Event_1ic2bhx_di" bpmnElement="Event_1ic2bhx">
|
||||||
|
<dc:Bounds x="782" y="222" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
<bpmndi:BPMNShape id="inlineSubprocess_2_di" bpmnElement="inlineSubprocess_2">
|
<bpmndi:BPMNShape id="inlineSubprocess_2_di" bpmnElement="inlineSubprocess_2">
|
||||||
<dc:Bounds x="350" y="120" width="390" height="240" />
|
<dc:Bounds x="350" y="120" width="390" height="240" />
|
||||||
</bpmndi:BPMNShape>
|
</bpmndi:BPMNShape>
|
||||||
<bpmndi:BPMNShape id="subprocess_startEvent_di" bpmnElement="subprocess_startEvent">
|
<bpmndi:BPMNShape id="subprocess_startEvent_di" bpmnElement="subprocess_startEvent">
|
||||||
<dc:Bounds x="410" y="222" width="36" height="36" />
|
<dc:Bounds x="410" y="222" width="36" height="36" />
|
||||||
</bpmndi:BPMNShape>
|
</bpmndi:BPMNShape>
|
||||||
<bpmndi:BPMNShape id="Event_1ic2bhx_di" bpmnElement="Event_1ic2bhx">
|
<bpmndi:BPMNShape id="Activity_1hpaeri_di" bpmnElement="emptyProcess">
|
||||||
<dc:Bounds x="782" y="222" width="36" height="36" />
|
<dc:Bounds x="960" y="50" width="100" height="80" />
|
||||||
</bpmndi:BPMNShape>
|
</bpmndi:BPMNShape>
|
||||||
</bpmndi:BPMNPlane>
|
</bpmndi:BPMNPlane>
|
||||||
</bpmndi:BPMNDiagram>
|
</bpmndi:BPMNDiagram>
|
||||||
|
|
|
@ -197,6 +197,71 @@ describe('features/modeling/behavior - subprocess planes', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('remove', function() {
|
||||||
|
|
||||||
|
var multipleDiagramXML = require('./SubProcessBehavior.multiple-planes.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(multipleDiagramXML, {
|
||||||
|
modules: [
|
||||||
|
coreModule,
|
||||||
|
modelingModule,
|
||||||
|
replaceModule
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should recursively remove diagrams', inject(function(elementRegistry, modeling, bpmnjs) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_2');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.removeShape(subProcess);
|
||||||
|
|
||||||
|
// then
|
||||||
|
var nestedTask = elementRegistry.get('nested_task');
|
||||||
|
var diagrams = bpmnjs.getDefinitions().diagrams;
|
||||||
|
expect(diagrams.length).to.equal(1);
|
||||||
|
expect(nestedTask).to.not.exist;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should undo', inject(function(elementRegistry, modeling, bpmnjs, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_2');
|
||||||
|
modeling.removeShape(subProcess);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
var nestedTask = elementRegistry.get('nested_task');
|
||||||
|
var diagrams = bpmnjs.getDefinitions().diagrams;
|
||||||
|
expect(diagrams.length).to.equal(3);
|
||||||
|
expect(nestedTask).to.exist;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should undo', inject(function(elementRegistry, modeling, bpmnjs, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcess = elementRegistry.get('SubProcess_2');
|
||||||
|
modeling.removeShape(subProcess);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.redo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
var nestedTask = elementRegistry.get('nested_task');
|
||||||
|
var diagrams = bpmnjs.getDefinitions().diagrams;
|
||||||
|
expect(diagrams.length).to.equal(1);
|
||||||
|
expect(nestedTask).to.not.exist;
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue