From ef52dff84cc84ec8c1c69b61da2822933eebe260 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Tue, 13 Feb 2018 16:58:46 +0100 Subject: [PATCH] fix(bpmn-replace): correctly replace sub process -> call activity * when not morphing collapsed sub process with children into expanded sub process children must be removed Related to camunda/camunda-modeler#739 --- lib/features/replace/BpmnReplace.js | 7 +++++++ test/spec/features/replace/BpmnReplaceSpec.js | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index 7bbfdbbe..6cb4473a 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -151,6 +151,13 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling, eventBus) { } } + // remove children if not expanding sub process + if (is(oldBusinessObject, 'bpmn:SubProcess') + && !isExpanded(oldBusinessObject) + && !is(newBusinessObject, 'bpmn:SubProcess')) { + hints.moveChildren = false; + } + // transform collapsed/expanded pools if (is(oldBusinessObject, 'bpmn:Participant')) { diff --git a/test/spec/features/replace/BpmnReplaceSpec.js b/test/spec/features/replace/BpmnReplaceSpec.js index 9f490e48..cadd73fa 100644 --- a/test/spec/features/replace/BpmnReplaceSpec.js +++ b/test/spec/features/replace/BpmnReplaceSpec.js @@ -853,6 +853,25 @@ describe('features/replace - bpmn replace', function() { }) ); + + it('should remove children of collapsed sub process not morphing into expanded', + inject(function(bpmnReplace, elementRegistry, modeling) { + + // given + var element = elementRegistry.get('SubProcess_1'); + var newElementData = { + type: 'bpmn:CallActivity' + }; + + modeling.toggleCollapse(element); + + // when + var newElement = bpmnReplace.replaceElement(element, newElementData); + + // then + expect(is(newElement, 'bpmn:CallActivity')).to.be.true; + })); + });