feat(di-ordering): support multi-root diagrams
This commit is contained in:
parent
8563bb2a4b
commit
aaee4476f6
|
@ -2,6 +2,7 @@ import { getDi } from '../../util/ModelUtil';
|
|||
|
||||
import {
|
||||
filter,
|
||||
forEach,
|
||||
map
|
||||
} from 'min-dash';
|
||||
|
||||
|
@ -15,21 +16,24 @@ export default function BpmnDiOrdering(eventBus, canvas) {
|
|||
eventBus.on('saveXML.start', HIGH_PRIORITY, orderDi);
|
||||
|
||||
function orderDi() {
|
||||
var root = canvas.getRootElement(),
|
||||
rootDi = getDi(root),
|
||||
elements,
|
||||
diElements;
|
||||
var rootElements = canvas.getRootElements();
|
||||
|
||||
elements = selfAndAllChildren([ root ], false);
|
||||
forEach(rootElements, function(root) {
|
||||
var rootDi = getDi(root),
|
||||
elements,
|
||||
diElements;
|
||||
|
||||
// only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
|
||||
elements = filter(elements, function(element) {
|
||||
return element !== root && !element.labelTarget;
|
||||
elements = selfAndAllChildren([ root ], false);
|
||||
|
||||
// only bpmndi:Shape and bpmndi:Edge can be direct children of bpmndi:Plane
|
||||
elements = filter(elements, function(element) {
|
||||
return element !== root && !element.labelTarget;
|
||||
});
|
||||
|
||||
diElements = map(elements, getDi);
|
||||
|
||||
rootDi.set('planeElement', diElements);
|
||||
});
|
||||
|
||||
diElements = map(elements, getDi);
|
||||
|
||||
rootDi.set('planeElement', diElements);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,33 @@ describe('features/modeling - di ordering', function() {
|
|||
task1.id,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should order subprocess planes', function() {
|
||||
|
||||
// given
|
||||
var canvas = getBpmnJS().get('canvas'),
|
||||
root;
|
||||
|
||||
// when
|
||||
var subProcess = add(
|
||||
{ type: 'bpmn:SubProcess', isExpanded: false, width: 300, height: 200 }, { x: 300, y: 200 }
|
||||
);
|
||||
|
||||
var participant = add({ type: 'bpmn:Participant', width: 500, height: 300 }, { x: 300, y: 200 }),
|
||||
task1 = add({ type: 'bpmn:Task' }, { x: 250, y: 200 }, subProcess.id + '_plane');
|
||||
|
||||
root = canvas.getRootElement();
|
||||
|
||||
// then
|
||||
// subProcess id exists twice: once as collapsed shape and once as plane element
|
||||
return expectDiOrder([
|
||||
root.id,
|
||||
participant.id,
|
||||
subProcess.id,
|
||||
subProcess.id,
|
||||
task1.id,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue