fix(modeling): limit flow join behavior to bpmn:SequenceFlows

Closes #917
This commit is contained in:
Nico Rehwaldt 2018-11-29 16:27:12 +01:00 committed by merge-me[bot]
parent 60036cdeda
commit 7aad42d178
3 changed files with 93 additions and 8 deletions

View File

@ -1,5 +1,7 @@
import inherits from 'inherits';
import { is } from '../../../util/ModelUtil';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import lineIntersect from './util/LineIntersect';
@ -18,11 +20,18 @@ export default function RemoveElementBehavior(eventBus, bpmnRules, modeling) {
var shape = e.context.shape;
if (shape.incoming.length == 1 && shape.outgoing.length == 1) {
// only handle [a] -> [shape] -> [b] patterns
if (shape.incoming.length !== 1 || shape.outgoing.length !== 1) {
return;
}
var inConnection = shape.incoming[0],
outConnection = shape.outgoing[0];
// only handle sequence flows
if (!is(inConnection, 'bpmn:SequenceFlow') || !is(outConnection, 'bpmn:SequenceFlow')) {
return;
}
if (bpmnRules.canConnect(inConnection.source, outConnection.target, inConnection)) {
@ -31,7 +40,6 @@ export default function RemoveElementBehavior(eventBus, bpmnRules, modeling) {
modeling.reconnectEnd(inConnection, outConnection.target, newWaypoints);
}
}
});
}

View File

@ -0,0 +1,46 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.5.0">
<bpmn:collaboration id="Collaboration_16ydlxc">
<bpmn:participant id="Participant_1" name="Participant_1" processRef="Process_1" />
<bpmn:participant id="Participant_2" name="Participant_2" processRef="Process_2" />
<bpmn:messageFlow id="MessageFlow_1" sourceRef="Task_A" targetRef="Task_B" />
<bpmn:messageFlow id="MessageFlow_2" sourceRef="Task_B" targetRef="Task_A" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:laneSet />
<bpmn:task id="Task_B" name="Task_B" />
</bpmn:process>
<bpmn:process id="Process_2" isExecutable="false">
<bpmn:task id="Task_A" name="Task_A" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_16ydlxc">
<bpmndi:BPMNShape id="Participant_1_di" bpmnElement="Participant_1">
<dc:Bounds x="94" y="483" width="372" height="149" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_B_di" bpmnElement="Task_B">
<dc:Bounds x="332" y="532" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_2_di" bpmnElement="Participant_2">
<dc:Bounds x="96" y="40" width="383" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_A_di" bpmnElement="Task_A">
<dc:Bounds x="332" y="61" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="MessageFlow_1_di" bpmnElement="MessageFlow_1">
<di:waypoint x="400" y="141" />
<di:waypoint x="402" y="532" />
<bpmndi:BPMNLabel>
<dc:Bounds x="815" y="301.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_2_di" bpmnElement="MessageFlow_2">
<di:waypoint x="366" y="532" />
<di:waypoint x="366" y="141" />
<bpmndi:BPMNLabel>
<dc:Bounds x="795" y="316.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -317,6 +317,37 @@ describe('features/replace - bpmn replace', function() {
});
describe('should collapse pool, removing message flows', function() {
var diagramXML = require('./BpmnReplace.poolMessageFlows.bpmn');
beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
}));
it('expanded with collapsed pool', inject(function(elementRegistry, bpmnReplace) {
// given
var shape = elementRegistry.get('Participant_1');
// when
var newShape = bpmnReplace.replaceElement(shape, {
type: 'bpmn:Participant',
isExpanded: false
});
// then
expect(isExpanded(newShape)).to.be.false; // collapsed
expect(newShape.children).to.be.empty;
expect(elementRegistry.get('MessageFlow_1')).not.to.exist;
expect(elementRegistry.get('MessageFlow_2')).not.to.exist;
}));
});
describe('should replace with data objects', function() {
var diagramXML = require('./BpmnReplace.dataObjects.bpmn');