From 6ed51fc03601713062840c782e2c01badc0d3587 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Mon, 12 Aug 2019 16:21:49 +0200 Subject: [PATCH] fix(rules): allow to create attachments Related to https://github.com/camunda/camunda-modeler/issues/1462 --- lib/features/rules/BpmnRules.js | 4 +++ test/spec/features/rules/BpmnRulesSpec.js | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 895421b8..c3eab9ff 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -128,6 +128,10 @@ BpmnRules.prototype.init = function() { return canConnect(element.source, element.target, element); } + if (element.host) { + return canAttach(element, element.host, null, position); + } + return canCreate(element, target, null, position); }); }); diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index a0bd74cf..3fe6e2b5 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -81,6 +81,36 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanCreate([ task1, task2, sequenceFlow ], 'Process', false); })); + + it('create task and non-interrupting boundary event', inject(function(elementFactory) { + + // given + var task = elementFactory.createShape({ type: 'bpmn:Task' }), + boundaryEvent = elementFactory.createShape({ + type: 'bpmn:BoundaryEvent', + eventDefinitionType: 'bpmn:EscalationEventDefinition', + cancelActivity: false, + host: task + }); + + // then + expectCanCreate([ task, boundaryEvent ], 'Process', true); + })); + + + it('create task and interrupting boundary event', inject(function(elementFactory) { + + // given + var task = elementFactory.createShape({ type: 'bpmn:Task' }), + boundaryEvent = elementFactory.createShape({ + type: 'bpmn:BoundaryEvent', + eventDefinitionType: 'bpmn:EscalationEventDefinition', + host: task + }); + + // then + expectCanCreate([ task, boundaryEvent ], 'Process', true); + })); });