You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
920 B
41 lines
920 B
2 years ago
|
import { getDi } from '../../util/ModelUtil';
|
||
|
|
||
|
import {
|
||
|
filter,
|
||
|
forEach,
|
||
|
map
|
||
|
} from 'min-dash';
|
||
|
|
||
|
import { selfAndAllChildren } from 'diagram-js/lib/util/Elements';
|
||
|
|
||
|
|
||
|
var HIGH_PRIORITY = 2000;
|
||
|
|
||
|
export default function BpmnDiOrdering(eventBus, canvas) {
|
||
|
|
||
|
eventBus.on('saveXML.start', HIGH_PRIORITY, orderDi);
|
||
|
|
||
|
function orderDi() {
|
||
|
var rootElements = canvas.getRootElements();
|
||
|
|
||
|
forEach(rootElements, function(root) {
|
||
|
var rootDi = getDi(root),
|
||
|
elements,
|
||
|
diElements;
|
||
|
|
||
|
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);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BpmnDiOrdering.$inject = [ 'eventBus', 'canvas' ];
|