fix(rules): do not allow message flows to outside diagram shapes

Closes #1033
This commit is contained in:
Nico Rehwaldt 2019-05-17 11:57:12 +02:00 committed by merge-me[bot]
parent 87bfe23ff8
commit 576a3dec15
3 changed files with 62 additions and 3 deletions

View File

@ -827,9 +827,17 @@ function canConnectAssociation(source, target) {
function canConnectMessageFlow(source, target) {
return isMessageFlowSource(source) &&
isMessageFlowTarget(target) &&
!isSameOrganization(source, target);
// handle the case where target does not have a parent,
// because it is not dropped within the diagram (bpmn-io/bpmn-js#1033)
if (!target.parent) {
return false;
}
return (
isMessageFlowSource(source) &&
isMessageFlowTarget(target) &&
!isSameOrganization(source, target)
);
}
function canConnectSequenceFlow(source, target) {

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="3.4.0">
<process id="Process_1" isExecutable="false">
<task id="Task_A" name="A" />
</process>
<bpmndi:BPMNDiagram id="BpmnDiagram_1">
<bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Task_A_di" bpmnElement="Task_A">
<omgdc:Bounds x="156" y="81" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

View File

@ -1441,6 +1441,7 @@ describe('features/modeling/rules - BpmnRules', function() {
}
));
it('not attach IntermediateEvent to ReceiveTask after EventBasedGateway', inject(
function(canvas, modeling, elementFactory, bpmnRules) {
@ -1477,6 +1478,7 @@ describe('features/modeling/rules - BpmnRules', function() {
}
));
it('create IntermediateEvent in SubProcess body', inject(
function(elementFactory, elementRegistry, bpmnRules) {
@ -1791,6 +1793,41 @@ describe('features/modeling/rules - BpmnRules', function() {
});
describe('connect on create', function() {
var testXML = require('./BpmnRules.connectOnCreate.bpmn');
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
it('should handle target without parent', inject(function(elementFactory) {
// given
var types = [
'bpmn:Task',
'bpmn:StartEvent',
'bpmn:EndEvent',
'bpmn:Gateway'
];
types.forEach(function(type) {
// when
var element = elementFactory.createShape({ type: type });
// then
expectCanConnect('Task_A', element, {
sequenceFlow: false,
messageFlow: false,
association: false,
dataAssociation: false
});
});
}));
});
describe('data input / output', function() {
describe('in process', function() {
@ -1888,6 +1925,7 @@ describe('features/modeling/rules - BpmnRules', function() {
});
describe('start connection', function() {
var testXML = require('../../../fixtures/bpmn/simple.bpmn');