From b56604d5f350a12c9ab1175b5c1a2d36a79a3140 Mon Sep 17 00:00:00 2001 From: Martin Stamm Date: Tue, 4 May 2021 09:15:48 +0200 Subject: [PATCH] fix(paste): don't insert multiple shapes on flow closes #1440 --- lib/features/rules/BpmnRules.js | 4 + .../features/rules/BpmnRules.process.bpmn | 113 ++++++++++-------- test/spec/features/rules/BpmnRulesSpec.js | 12 ++ 3 files changed, 81 insertions(+), 48 deletions(-) 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); + })); + });