feat(modeling): support morphing to AdhocSubprocess

This commit is contained in:
Martin Stamm 2021-12-15 17:35:34 +01:00 committed by Nico Rehwaldt
parent 12fe06bfa6
commit 2e672d0e24
1 changed files with 28 additions and 0 deletions

View File

@ -95,6 +95,34 @@ export default function SubProcessPlaneBehavior(
}, true); }, true);
this.preExecuted('shape.replace', function(context) {
var oldShape = context.oldShape;
var newShape = context.newShape;
if (!isCollapsedSubProcess(oldShape) || !isCollapsedSubProcess(newShape)) {
return;
}
// old plane could have content,
// we remove it so it is not recursively deleted from 'shape.delete'
context.oldRoot = canvas.removeRootElement(planeId(oldShape));
}, true);
this.postExecuted('shape.replace', function(context) {
var newShape = context.newShape,
source = context.oldRoot,
target = canvas.findRoot(planeId(newShape));
if (!source || !target) {
return;
}
var elements = source.children;
modeling.moveElements(elements, { x: 0, y: 0 }, target);
}, true);
// rename secondary elements (roots) when the primary element changes // rename secondary elements (roots) when the primary element changes
// this ensures rootElement.id = element.id + '_plane' // this ensures rootElement.id = element.id + '_plane'
this.executed('element.updateProperties', function(context) { this.executed('element.updateProperties', function(context) {