diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 3d56d54d..24e3b67d 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -115,6 +115,10 @@ BpmnRules.prototype.init = function() { position = context.position, target = context.target; + if (isConnection(target) && !canInsert(elements, target, position)) { + return false; + } + return every(elements, function(element) { if (isConnection(element)) { return canConnect(element.source, element.target, element); diff --git a/test/spec/features/rules/BpmnRules.process.bpmn b/test/spec/features/rules/BpmnRules.process.bpmn index f468c831..fcd41cb2 100644 --- a/test/spec/features/rules/BpmnRules.process.bpmn +++ b/test/spec/features/rules/BpmnRules.process.bpmn @@ -1,99 +1,116 @@ - + - + - + - + - + - + - + - - - - - - + + + + + + + SequenceFlow + + + SequenceFlow + + + - + - - + + + + + + - + - + - - - - - - - - + + - + - + - + - + - - - - - - - - - - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + - + - + - \ No newline at end of file + diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index 10701eb5..a449caf8 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -111,6 +111,18 @@ describe('features/modeling/rules - BpmnRules', function() { // then expectCanCreate([ task, boundaryEvent ], 'Process', true); })); + + + it('can\'t create multiple elements on flow', inject(function(elementFactory) { + + // given + var task1 = elementFactory.createShape({ type: 'bpmn:Task' }), + task2 = elementFactory.createShape({ type: 'bpmn:Task' }); + + // then + expectCanCreate([task1, task2], 'SequenceFlow', false); + })); + });