fix(modeling/BpmnUpdater): restore children di when changing diagram type
closes #253
This commit is contained in:
parent
877cfcca78
commit
6f8999b8ae
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var assign = require('lodash/object/assign'),
|
||||
forEach = require('lodash/collection/forEach'),
|
||||
inherits = require('inherits');
|
||||
|
||||
var Collections = require('diagram-js/lib/util/Collections'),
|
||||
|
@ -71,6 +72,28 @@ function BpmnUpdater(eventBus, bpmnFactory, connectionDocking) {
|
|||
'connection.move',
|
||||
'connection.delete' ], updateParent);
|
||||
|
||||
/*
|
||||
* ## Updating Parent
|
||||
*
|
||||
* When morphing a Process into a Collaboration or vice-versa,
|
||||
* make sure that both the *semantic* and *di* parent of each element
|
||||
* is updated.
|
||||
*
|
||||
*/
|
||||
function updateRoot(event) {
|
||||
var context = event.context,
|
||||
oldRoot = context.oldRoot,
|
||||
children = oldRoot.children;
|
||||
|
||||
forEach(children, function(child) {
|
||||
self.updateParent(child);
|
||||
});
|
||||
}
|
||||
|
||||
this.executed([ 'canvas.updateRoot' ], updateRoot);
|
||||
this.reverted([ 'canvas.updateRoot' ], updateRoot);
|
||||
|
||||
|
||||
// update bounds
|
||||
function updateBounds(e) {
|
||||
self.updateBounds(e.context.shape);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var TestHelper = require('../TestHelper');
|
||||
|
||||
var Modeler = require('../../lib/Modeler');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
require('../TestHelper');
|
||||
var TestHelper = require('../TestHelper');
|
||||
|
||||
|
||||
var Viewer = require('../../lib/Viewer');
|
||||
|
|
|
@ -127,7 +127,7 @@ describe('features/modeling - create participant', function() {
|
|||
}));
|
||||
|
||||
|
||||
it('undo', inject(function(modeling, elementFactory, canvas, commandStack) {
|
||||
it('undo', inject(function(modeling, elementFactory, elementRegistry, canvas, commandStack) {
|
||||
|
||||
// given
|
||||
var processShape = canvas.getRootElement(),
|
||||
|
@ -138,10 +138,34 @@ describe('features/modeling - create participant', function() {
|
|||
// when
|
||||
commandStack.undo();
|
||||
|
||||
var startEventElement = elementRegistry.get('StartEvent_1'),
|
||||
startEventDi = startEventElement.businessObject.di,
|
||||
rootElement = canvas.getRootElement(),
|
||||
rootShapeDi = rootElement.businessObject.di;
|
||||
|
||||
// then
|
||||
expect(participantShape.children.length).toBe(0);
|
||||
expect(processShape.children.length).toBe(9);
|
||||
|
||||
// children di is wired
|
||||
expect(startEventDi.$parent).toEqual(rootShapeDi);
|
||||
expect(rootShapeDi.planeElement).toContain(startEventDi);
|
||||
}));
|
||||
|
||||
|
||||
it('should detach DI on update canvas root', inject(function(canvas, elementFactory, commandStack, modeling, elementRegistry) {
|
||||
|
||||
// when
|
||||
modeling.makeCollaboration();
|
||||
|
||||
var startEventElement = elementRegistry.get('StartEvent_1'),
|
||||
startEventDi = startEventElement.businessObject.di,
|
||||
rootElement = canvas.getRootElement(),
|
||||
rootShapeDi = rootElement.businessObject.di;
|
||||
|
||||
// then
|
||||
expect(startEventDi.$parent).toBeFalsy();
|
||||
expect(rootShapeDi.planeElement).not.toContain(startEventDi);
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue