fix(modeling): skip updating BPMN parent on label move

This commit is contained in:
Nico Rehwaldt 2014-11-27 11:55:38 +01:00
parent f363356fcb
commit 2258642cb4
2 changed files with 33 additions and 4 deletions

View File

@ -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,

View File

@ -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