diff --git a/lib/features/modeling/BpmnUpdater.js b/lib/features/modeling/BpmnUpdater.js index a7743508..40c05b26 100644 --- a/lib/features/modeling/BpmnUpdater.js +++ b/lib/features/modeling/BpmnUpdater.js @@ -4,6 +4,8 @@ var _ = require('lodash'); var Collections = require('diagram-js/lib/util/Collections'); +var Model = require('diagram-js/lib/model'); + /** * A handler responsible for updating the underlying BPMN 2.0 XML + DI @@ -99,6 +101,11 @@ BpmnUpdater.$inject = [ 'eventBus', 'bpmnFactory', 'connectionDocking']; BpmnUpdater.prototype.updateParent = function(element) { + // do not update BPMN 2.0 label parent + if (element instanceof Model.Label) { + return; + } + var parentShape = element.parent; var businessObject = element.businessObject, @@ -115,7 +122,7 @@ BpmnUpdater.prototype.updateBounds = function(shape) { var di = shape.businessObject.di; - var bounds = shape.type === 'label' ? this._getLabel(di).bounds : di.bounds; + var bounds = (shape instanceof Model.Label) ? this._getLabel(di).bounds : di.bounds; _.extend(bounds, { x: shape.x, diff --git a/test/spec/features/modeling/MoveShapeSpec.js b/test/spec/features/modeling/MoveShapeSpec.js index 7e89d6a1..7503b9ae 100644 --- a/test/spec/features/modeling/MoveShapeSpec.js +++ b/test/spec/features/modeling/MoveShapeSpec.js @@ -25,9 +25,9 @@ describe('features/modeling - move shape', function() { beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); - describe('shape handling', function() { + describe('shape', function() { - it('should execute', inject(function(elementRegistry, modeling) { + it('should move', inject(function(elementRegistry, modeling) { // given var startEventElement = elementRegistry.get('StartEvent_1'), @@ -65,7 +65,7 @@ describe('features/modeling - move shape', function() { })); - it('should execute on label', inject(function(elementRegistry, modeling) { + it('should move label', inject(function(elementRegistry, modeling) { // given var labelElement = elementRegistry.get('StartEvent_1_label'), @@ -85,6 +85,28 @@ describe('features/modeling - move shape', function() { })); + it('should move label to new parent', inject(function(elementRegistry, modeling) { + + // given + var startEventElement = elementRegistry.get('StartEvent_1'), + labelElement = elementRegistry.get('StartEvent_1_label'), + processElement = elementRegistry.get('Process_1'), + subProcessElement = elementRegistry.get('SubProcess_1'), + startEvent = labelElement.businessObject, + subProcess = subProcessElement.businessObject; + + // when + modeling.moveShape(labelElement, { x: 0, y: 50 }, processElement); + + // then + expect(labelElement.parent).toBe(processElement); + + // expect actual element + businessObject to be unchanged + expect(startEventElement.parent).toBe(subProcessElement); + expect(startEvent.$parent).toBe(subProcess); + })); + + it('should move label with element', inject(function(elementRegistry, modeling) { // given