From 890e4661619e960769af5bed8ff30aeee0418ac8 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Mon, 24 Jun 2019 13:16:11 +0200 Subject: [PATCH] fix(bpmn-rules): allow to drop Boundary Events only on containers Closes https://github.com/bpmn-io/bpmn-js/issues/1095 --- lib/features/rules/BpmnRules.js | 13 +++++++++---- test/spec/features/rules/BpmnRulesSpec.js | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index d2e14bb0..34f4d891 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -479,10 +479,9 @@ function canDrop(element, target, position) { return is(target, 'bpmn:Participant') || is(target, 'bpmn:Lane'); } - if (is(element, 'bpmn:BoundaryEvent')) { - return getBusinessObject(element).cancelActivity && ( - hasNoEventDefinition(element) || hasCommonBoundaryIntermediateEventDefinition(element) - ); + // disallow dropping boundary events which cannot replace with intermediate event + if (is(element, 'bpmn:BoundaryEvent') && !isDroppableBoundaryEvent(element)) { + return false; } // drop flow elements onto flow element containers @@ -517,6 +516,12 @@ function canDrop(element, target, position) { return false; } +function isDroppableBoundaryEvent(event) { + return getBusinessObject(event).cancelActivity && ( + hasNoEventDefinition(event) || hasCommonBoundaryIntermediateEventDefinition(event) + ); +} + function canPaste(tree, target) { var topLevel = tree[0], participants; diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index 03a3e9e5..d3ce9ab1 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -470,6 +470,10 @@ describe('features/modeling/rules - BpmnRules', function() { }); })); + + it('drop BoundaryEvent -> Task', function() { + expectCanDrop('BoundaryEvent_on_SubProcess', 'Task_in_OtherProcess', false); + }); });