From 1a4a8959fe16558afd18f626279de4bf6fcdc968 Mon Sep 17 00:00:00 2001 From: Ricardo Matias Date: Fri, 3 Feb 2017 14:58:41 +0100 Subject: [PATCH] fix(replace): make sure is respected for expanded sub processes Closes camunda/camunda-modeler#511 --- lib/features/replace/BpmnReplace.js | 2 +- test/spec/features/replace/BpmnReplaceSpec.js | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index fc5ca558..0be6b37a 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -143,7 +143,7 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling, eventBus) { // TODO: need also to respect min/max Size // copy size, from an expanded subprocess to an expanded alternative subprocess // except bpmn:Task, because Task is always expanded - if ((isExpanded(oldBusinessObject) && !is(oldBusinessObject, 'bpmn:Task')) && target.isExpanded) { + if ((isExpanded(oldBusinessObject) && !is(oldBusinessObject, 'bpmn:Task')) && newElement.isExpanded) { newElement.width = element.width; newElement.height = element.height; } diff --git a/test/spec/features/replace/BpmnReplaceSpec.js b/test/spec/features/replace/BpmnReplaceSpec.js index 5f66ca20..fed180f8 100644 --- a/test/spec/features/replace/BpmnReplaceSpec.js +++ b/test/spec/features/replace/BpmnReplaceSpec.js @@ -779,6 +779,38 @@ describe('features/replace - bpmn replace', function() { }) ); + + it('should keep size when morphing ad hoc', + inject(function(bpmnReplace, elementRegistry, modeling) { + + // given + var element = elementRegistry.get('SubProcess_1'); + var newElementData = { + type: 'bpmn:AdHocSubProcess' + }; + + var width = element.width, + height = element.height; + + modeling.resizeShape(element, { + x: element.x, + y: element.y, + width: width + 20, + height: height + 20 + }); + + // when + var newElement = bpmnReplace.replaceElement(element, newElementData); + + // then + expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.true; + expect(isExpanded(newElement)).to.be.true; + + expect(newElement.width).to.equal(width + 20); + expect(newElement.height).to.equal(height + 20); + }) + ); + });