fix(modeling): correct creation of nested lanes
With diagram-js@5 we've introduced the CreateBehavior that ensures elements are not created on top of lanes but always on top of the actual participant. Unfortunately we forgot about the fact that lanes are created once in a while, too. This commit accounts for this fact and ensures we do not adjust the parent of to-be-created lanes. (A test cases for splitting nested lanes did not exist until now). Closes #1254 Closes #1253
This commit is contained in:
parent
c8eedf959f
commit
b4b5d1d139
|
@ -12,9 +12,10 @@ export default function CreateBehavior(injector) {
|
||||||
|
|
||||||
this.preExecute('shape.create', 1500, function(event) {
|
this.preExecute('shape.create', 1500, function(event) {
|
||||||
var context = event.context,
|
var context = event.context,
|
||||||
parent = context.parent;
|
parent = context.parent,
|
||||||
|
shape = context.shape;
|
||||||
|
|
||||||
if (is(parent, 'bpmn:Lane')) {
|
if (is(parent, 'bpmn:Lane') && !is(shape, 'bpmn:Lane')) {
|
||||||
context.parent = getParent(parent, 'bpmn:Participant');
|
context.parent = getParent(parent, 'bpmn:Participant');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0czfmdy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
|
||||||
|
<bpmn:collaboration id="Collaboration_166yin4">
|
||||||
|
<bpmn:participant id="Participant" name="Participant" processRef="Process" />
|
||||||
|
</bpmn:collaboration>
|
||||||
|
<bpmn:process id="Process" isExecutable="true">
|
||||||
|
<bpmn:laneSet id="LaneSet_113taei">
|
||||||
|
<bpmn:lane id="Lane" name="Lane">
|
||||||
|
<bpmn:flowNodeRef>Event</bpmn:flowNodeRef>
|
||||||
|
<bpmn:flowNodeRef>Task</bpmn:flowNodeRef>
|
||||||
|
</bpmn:lane>
|
||||||
|
</bpmn:laneSet>
|
||||||
|
<bpmn:startEvent id="Event" name="Event">
|
||||||
|
<bpmn:outgoing>SequenceFlow_192h0e0</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:task id="Task" name="Task">
|
||||||
|
<bpmn:incoming>SequenceFlow_192h0e0</bpmn:incoming>
|
||||||
|
</bpmn:task>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_192h0e0" sourceRef="Event" targetRef="Task" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_166yin4">
|
||||||
|
<bpmndi:BPMNShape id="Participant_00t6m8v_di" bpmnElement="Participant" isHorizontal="true">
|
||||||
|
<dc:Bounds x="170" y="90" width="791" height="450" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Event">
|
||||||
|
<dc:Bounds x="323" y="152" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="327" y="195" width="29" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_05q93nk_di" bpmnElement="Task">
|
||||||
|
<dc:Bounds x="411" y="130" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_192h0e0_di" bpmnElement="SequenceFlow_192h0e0">
|
||||||
|
<di:waypoint x="359" y="170" />
|
||||||
|
<di:waypoint x="411" y="170" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="Lane_1f7sfho_di" bpmnElement="Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds x="200" y="90" width="761" height="450" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -18,12 +18,13 @@ function getBounds(element) {
|
||||||
|
|
||||||
describe('features/modeling - SplitLane', function() {
|
describe('features/modeling - SplitLane', function() {
|
||||||
|
|
||||||
|
var testModules = [ coreModule, modelingModule ];
|
||||||
|
|
||||||
|
|
||||||
describe('should split Participant with Lane', function() {
|
describe('should split Participant with Lane', function() {
|
||||||
|
|
||||||
var diagramXML = require('./participant-lane.bpmn');
|
var diagramXML = require('./participant-lane.bpmn');
|
||||||
|
|
||||||
var testModules = [ coreModule, modelingModule ];
|
|
||||||
|
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,8 +125,6 @@ describe('features/modeling - SplitLane', function() {
|
||||||
|
|
||||||
var diagramXML = require('./participant-no-lane.bpmn');
|
var diagramXML = require('./participant-no-lane.bpmn');
|
||||||
|
|
||||||
var testModules = [ coreModule, modelingModule ];
|
|
||||||
|
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ describe('features/modeling - SplitLane', function() {
|
||||||
expect(participantShape).to.have.bounds(oldBounds);
|
expect(participantShape).to.have.bounds(oldBounds);
|
||||||
|
|
||||||
// and two child lanes
|
// and two child lanes
|
||||||
expect(childLanes.length).to.eql(2);
|
expect(childLanes).to.have.length(2);
|
||||||
|
|
||||||
// with respective bounds
|
// with respective bounds
|
||||||
expect(childLanes[0]).to.have.bounds({
|
expect(childLanes[0]).to.have.bounds({
|
||||||
|
@ -186,7 +185,7 @@ describe('features/modeling - SplitLane', function() {
|
||||||
expect(participantShape).to.have.bounds(oldBounds);
|
expect(participantShape).to.have.bounds(oldBounds);
|
||||||
|
|
||||||
// and two child lanes
|
// and two child lanes
|
||||||
expect(childLanes.length).to.eql(3);
|
expect(childLanes).to.have.length(3);
|
||||||
|
|
||||||
// with respective bounds
|
// with respective bounds
|
||||||
expect(childLanes[0]).to.have.bounds({
|
expect(childLanes[0]).to.have.bounds({
|
||||||
|
@ -213,4 +212,60 @@ describe('features/modeling - SplitLane', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('should split nested Lane', function() {
|
||||||
|
|
||||||
|
var diagramXML = require('./SplitLane.nested.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
it('into two lanes', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var laneShape = elementRegistry.get('Lane'),
|
||||||
|
laneBo = laneShape.businessObject,
|
||||||
|
oldBounds = getBounds(laneShape);
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.splitLane(laneShape, 2);
|
||||||
|
|
||||||
|
var childLanes = getChildLanes(laneShape);
|
||||||
|
|
||||||
|
var newLaneHeight = Math.round(laneShape.height / 2);
|
||||||
|
|
||||||
|
// then
|
||||||
|
|
||||||
|
// participant has original size
|
||||||
|
expect(laneShape).to.have.bounds(oldBounds);
|
||||||
|
|
||||||
|
// and two child lanes
|
||||||
|
expect(childLanes).to.have.length(2);
|
||||||
|
|
||||||
|
// with respective bounds
|
||||||
|
expect(childLanes[0]).to.have.bounds({
|
||||||
|
x: laneShape.x + 30,
|
||||||
|
y: laneShape.y,
|
||||||
|
width: laneShape.width - 30,
|
||||||
|
height: newLaneHeight
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(childLanes[1]).to.have.bounds({
|
||||||
|
x: laneShape.x + 30,
|
||||||
|
y: laneShape.y + newLaneHeight,
|
||||||
|
width: laneShape.width - 30,
|
||||||
|
height: newLaneHeight
|
||||||
|
});
|
||||||
|
|
||||||
|
// BPMN internals are properly updated
|
||||||
|
expect(laneBo.childLaneSet).to.exist;
|
||||||
|
expect(laneBo.childLaneSet.lanes).to.eql([
|
||||||
|
childLanes[0].businessObject,
|
||||||
|
childLanes[1].businessObject
|
||||||
|
]);
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue