parent
6e4ae72eea
commit
63d0321210
|
@ -22,7 +22,8 @@ function BpmnOrderingProvider(eventBus) {
|
|||
OrderingProvider.call(this, eventBus);
|
||||
|
||||
var orders = [
|
||||
{ type: 'label', order: { level: 7 } },
|
||||
{ type: 'label', order: { level: 10 } },
|
||||
{ type: 'bpmn:SubProcess', order: { level: 6 } },
|
||||
{
|
||||
type: 'bpmn:SequenceFlow',
|
||||
order: {
|
||||
|
@ -44,8 +45,8 @@ function BpmnOrderingProvider(eventBus) {
|
|||
]
|
||||
}
|
||||
},
|
||||
{ type: 'bpmn:MessageFlow', order: { level: 6, containers: [ 'bpmn:Collaboration' ] } },
|
||||
{ type: 'bpmn:BoundaryEvent', order: { level: 4 } },
|
||||
{ type: 'bpmn:MessageFlow', order: { level: 9, containers: [ 'bpmn:Collaboration' ] } },
|
||||
{ type: 'bpmn:BoundaryEvent', order: { level: 8 } },
|
||||
{ type: 'bpmn:Participant', order: { level: -2 } },
|
||||
{ type: 'bpmn:Lane', order: { level: -1 } }
|
||||
];
|
||||
|
@ -135,4 +136,4 @@ BpmnOrderingProvider.$inject = [ 'eventBus' ];
|
|||
|
||||
inherits(BpmnOrderingProvider, OrderingProvider);
|
||||
|
||||
module.exports = BpmnOrderingProvider;
|
||||
module.exports = BpmnOrderingProvider;
|
||||
|
|
|
@ -13,40 +13,88 @@ var modelingModule = require('../../../../lib/features/modeling'),
|
|||
|
||||
describe('features/modeling - ordering', function() {
|
||||
|
||||
var diagramXML = require('./ordering.bpmn');
|
||||
|
||||
var testModules = [ coreModule, modelingModule ];
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
describe('boundary events', function() {
|
||||
|
||||
var diagramXML = require('./ordering.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
it('should stay in front of Task', inject(function() {
|
||||
|
||||
// when
|
||||
move('Task_With_Boundary');
|
||||
|
||||
// then
|
||||
expectZOrder('Task_With_Boundary', 'BoundaryEvent');
|
||||
}));
|
||||
|
||||
|
||||
it('should keep Task behind BoundaryEvent', inject(function() {
|
||||
it('should stay in front of Task, moving both', inject(function() {
|
||||
|
||||
// when
|
||||
move('Task_With_Boundary');
|
||||
// when
|
||||
move([ 'BoundaryEvent', 'Task_With_Boundary' ], 'Participant_StartEvent');
|
||||
|
||||
// then
|
||||
expectZOrder('Task_With_Boundary', 'BoundaryEvent');
|
||||
}));
|
||||
// then
|
||||
expectZOrder('Task_With_Boundary', 'BoundaryEvent');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('participants', function() {
|
||||
|
||||
var diagramXML = require('./ordering.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
it('should stay behind MessageFlow', inject(function() {
|
||||
|
||||
// when
|
||||
move('Participant', 'Collaboration');
|
||||
|
||||
// then
|
||||
expectZOrder('Participant_StartEvent', 'Participant', 'MessageFlow');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should keep Task behind BoundaryEvent, moving both', inject(function() {
|
||||
describe('sub processes', function() {
|
||||
|
||||
// when
|
||||
move([ 'BoundaryEvent', 'Task_With_Boundary' ], 'Participant_StartEvent');
|
||||
var diagramXML = require('./ordering-subprocesses.bpmn');
|
||||
|
||||
// then
|
||||
expectZOrder('Task_With_Boundary', 'BoundaryEvent');
|
||||
}));
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
it('should stay behind boundary events', inject(function() {
|
||||
|
||||
// when
|
||||
move('BoundaryEvent_1', { x: 50, y: 0 }, 'SubProcess_1', true);
|
||||
|
||||
// then
|
||||
expectZOrder('SubProcess_1', 'BoundaryEvent_1');
|
||||
}));
|
||||
|
||||
|
||||
it('should keep Participant behind MessageFlow', inject(function() {
|
||||
it('should stay behind tasks', inject(function() {
|
||||
|
||||
// when
|
||||
move('Participant', 'Collaboration');
|
||||
// when
|
||||
move(['Task_1', 'Task_2'], { x: 50, y: 0 }, 'SubProcess_1');
|
||||
|
||||
// then
|
||||
expectZOrder('Participant_StartEvent', 'Participant', 'MessageFlow');
|
||||
}));
|
||||
// then
|
||||
expectZOrder('SubProcess_1', 'Task_1', 'Task_2');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
it('should be in front of tasks if task is not a child', inject(function() {
|
||||
|
||||
// when
|
||||
move(['Task_1', 'Task_2'], { x: 200, y: 0 }, 'Root');
|
||||
|
||||
// then
|
||||
expectZOrder('Task_1', 'Task_2', 'SubProcess_1');
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -4,6 +4,16 @@ var TestHelper = require('../../../TestHelper');
|
|||
|
||||
var map = require('lodash/collection/map');
|
||||
|
||||
// polyfill, because Math.sign is not available in PhantomJS, IE and Safari
|
||||
// https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
|
||||
Math.sign = Math.sign || function(x) {
|
||||
x = +x; // convert to a number
|
||||
if (x === 0 || isNaN(x)) {
|
||||
return x;
|
||||
}
|
||||
return x > 0 ? 1 : -1;
|
||||
};
|
||||
|
||||
function move(elementIds, delta, targetId, isAttach) {
|
||||
|
||||
if (typeof elementIds === 'string') {
|
||||
|
@ -21,18 +31,25 @@ function move(elementIds, delta, targetId, isAttach) {
|
|||
targetId = null;
|
||||
}
|
||||
|
||||
return TestHelper.getBpmnJS().invoke(function(elementRegistry, modeling) {
|
||||
return TestHelper.getBpmnJS().invoke(function(canvas, elementRegistry, modeling) {
|
||||
|
||||
function getElement(id) {
|
||||
|
||||
var element = elementRegistry.get(id);
|
||||
|
||||
expect(element).to.exist;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
var elements = map(elementIds, getElement),
|
||||
target = targetId && getElement(targetId);
|
||||
target;
|
||||
|
||||
if (targetId === 'Root') {
|
||||
target = canvas.getRootElement();
|
||||
} else {
|
||||
target = targetId && getElement(targetId);
|
||||
}
|
||||
|
||||
return modeling.moveElements(elements, delta, target, isAttach);
|
||||
});
|
||||
|
@ -93,7 +110,7 @@ function compareZOrder(aId, bId) {
|
|||
parent: aAncestor
|
||||
};
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
|
||||
// b contained in a
|
||||
if (!sharedRoot.a) {
|
||||
|
@ -105,8 +122,8 @@ function compareZOrder(aId, bId) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
var aIndex = sharedRoot.parent.indexOf(sharedRoot.a),
|
||||
bIndex = sharedRoot.parent.indexOf(sharedRoot.b);
|
||||
var aIndex = sharedRoot.parent.children.indexOf(sharedRoot.a),
|
||||
bIndex = sharedRoot.parent.children.indexOf(sharedRoot.b);
|
||||
|
||||
return Math.sign(aIndex - bIndex);
|
||||
}
|
||||
|
@ -122,7 +139,7 @@ function expectZOrder() {
|
|||
|
||||
forEach(elements, function(e, idx) {
|
||||
|
||||
next = elements[idx];
|
||||
next = elements[idx + 1];
|
||||
|
||||
if (next) {
|
||||
expect(compareZOrder(e, next)).to.eql(-1);
|
||||
|
@ -132,4 +149,4 @@ function expectZOrder() {
|
|||
return true;
|
||||
}
|
||||
|
||||
module.exports.expectZOrder = expectZOrder;
|
||||
module.exports.expectZOrder = expectZOrder;
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:subProcess id="SubProcess_1">
|
||||
<bpmn:task id="Task_1" />
|
||||
<bpmn:task id="Task_2" />
|
||||
</bpmn:subProcess>
|
||||
<bpmn:boundaryEvent id="BoundaryEvent_1" attachedToRef="SubProcess_1" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="SubProcess_1_di" bpmnElement="SubProcess_1" isExpanded="true">
|
||||
<dc:Bounds x="100" y="44" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="BoundaryEvent_1_di" bpmnElement="BoundaryEvent_1">
|
||||
<dc:Bounds x="157" y="226" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="130" y="262" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
|
||||
<dc:Bounds x="138" y="68" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_2_di" bpmnElement="Task_2">
|
||||
<dc:Bounds x="305" y="68" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
Loading…
Reference in New Issue