From 749120c4e93492287888133850370ac726f81729 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 9 Jun 2015 11:04:05 +0200 Subject: [PATCH] fix(modeling): allow only bpmn:FlowNode(s) to be dropped on flow Closes #297 --- lib/features/modeling/rules/BpmnRules.js | 2 +- .../behavior/CreateOnFlowBehaviorSpec.js | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/features/modeling/rules/BpmnRules.js b/lib/features/modeling/rules/BpmnRules.js index 00b24c98..922d6b00 100644 --- a/lib/features/modeling/rules/BpmnRules.js +++ b/lib/features/modeling/rules/BpmnRules.js @@ -399,5 +399,5 @@ function canInsert(shape, flow) { return ( is(flow, 'bpmn:SequenceFlow') || is(flow, 'bpmn:MessageFlow') - ) && canDrop(shape, flow.parent); + ) && is(shape, 'bpmn:FlowNode') && canDrop(shape, flow.parent); } \ No newline at end of file diff --git a/test/spec/features/modeling/behavior/CreateOnFlowBehaviorSpec.js b/test/spec/features/modeling/behavior/CreateOnFlowBehaviorSpec.js index 9d5f80bc..cebd6312 100644 --- a/test/spec/features/modeling/behavior/CreateOnFlowBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/CreateOnFlowBehaviorSpec.js @@ -137,6 +137,30 @@ describe('modeling/behavior - drop on connection', function(){ { original: { x: 502, y: 299 }, x: 502, y: 299 } ]); })); + }); + + + describe('rules', function() { + + it('should not insert participant', inject(function(rules, elementRegistry, elementFactory) { + + // given + var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' }); + + var sequenceFlow = elementRegistry.get('SequenceFlow'); + + var position = { x: 340, y: 120 }; // first bendpoint + + // when + var canDrop = rules.allowed('shape.create', { + shape: participantShape, + parent: sequenceFlow, + position: position + }); + + // then + expect(canDrop).toBe(false); + })); });