diff --git a/lib/features/ordering/BpmnOrderingProvider.js b/lib/features/ordering/BpmnOrderingProvider.js index 86de5c1c..58d1f4a5 100644 --- a/lib/features/ordering/BpmnOrderingProvider.js +++ b/lib/features/ordering/BpmnOrderingProvider.js @@ -15,10 +15,10 @@ import { /** * a simple ordering provider that makes sure: * + * (0) labels are rendered always on top * (1) elements are ordered by a {level} property - * (2) elements with {alwaysOnTop} are always added to the root */ -export default function BpmnOrderingProvider(eventBus, translate) { +export default function BpmnOrderingProvider(eventBus, canvas, translate) { OrderingProvider.call(this, eventBus); @@ -116,6 +116,14 @@ export default function BpmnOrderingProvider(eventBus, translate) { this.getOrdering = function(element, newParent) { + // render labels always on top + if (element.labelTarget) { + return { + parent: canvas.getRootElement(), + index: -1 + }; + } + var elementOrder = getOrder(element); @@ -156,6 +164,6 @@ export default function BpmnOrderingProvider(eventBus, translate) { }; } -BpmnOrderingProvider.$inject = [ 'eventBus', 'translate' ]; +BpmnOrderingProvider.$inject = [ 'eventBus', 'canvas', 'translate' ]; inherits(BpmnOrderingProvider, OrderingProvider); \ No newline at end of file diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index 0d83397c..8d289a07 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -117,7 +117,9 @@ describe('features/copy-paste', function() { }); // then - expect(rootElement.children).to.have.length(3); + // 3 sub-processes + // 6 pasted labels + expect(rootElement.children).to.have.length(9); var pastedElements = elementRegistry.filter(function(e) { return e !== element && is(e, 'bpmn:SubProcess'); diff --git a/test/spec/features/ordering/BpmnOrderingProviderSpec.js b/test/spec/features/ordering/BpmnOrderingProviderSpec.js index 42130b28..6caba6f8 100644 --- a/test/spec/features/ordering/BpmnOrderingProviderSpec.js +++ b/test/spec/features/ordering/BpmnOrderingProviderSpec.js @@ -222,14 +222,63 @@ describe('features/modeling - ordering', function() { beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); - it('should always be in front', inject(function() { + describe('should stay always in front', function() { - // when - move('SequenceFlow_label', { x: 500, y: 0 }, 'Collaboration', false); + it('moving onto ', inject(function() { - // then - expectZOrder('Collaboration', 'Participant', 'SequenceFlow_label'); - })); + // when + move('SequenceFlow_label', { x: 300, y: 0 }, 'Collaboration', false); + + // then + expectZOrder('Collaboration', 'Participant', 'SequenceFlow_label'); + })); + + + it('moving onto ', inject(function() { + + // when + move('StartEvent_label', { x: 50, y: -330 }, 'Participant', false); + + // then + expectZOrder( + 'Participant', + 'Task_With_Boundary', + 'BoundaryEvent', + 'Participant_StartEvent', + 'StartEvent_label' + ); + })); + + + it('move with label onto ', inject(function() { + + // when + move('StartEvent', { x: 0, y: -330 }, 'Participant', false); + + // then + expectZOrder( + 'Participant', + 'Participant_StartEvent', + 'StartEvent_label' + ); + })); + + + it('move with label onto ', inject(function() { + + // when + move('DataStore', { x: -150, y: 330 }, 'Participant_StartEvent', false); + + // then + expectZOrder( + 'Participant', + 'Participant_StartEvent', + 'DataStore', + 'DataStore_label' + ); + })); + + }); }); diff --git a/test/spec/features/ordering/Helper.js b/test/spec/features/ordering/Helper.js index 7546ed2e..7b82943c 100644 --- a/test/spec/features/ordering/Helper.js +++ b/test/spec/features/ordering/Helper.js @@ -204,8 +204,10 @@ export function expectZOrder() { next = elements[idx + 1]; - if (next) { - expect(compareZOrder(e, next)).to.eql(-1); + if (next && compareZOrder(e, next) !== -1) { + throw new Error( + 'expected to be in front of ' + ); } }); diff --git a/test/spec/features/ordering/ordering.bpmn b/test/spec/features/ordering/ordering.bpmn index 40d0abc4..8c60d9ec 100644 --- a/test/spec/features/ordering/ordering.bpmn +++ b/test/spec/features/ordering/ordering.bpmn @@ -14,7 +14,7 @@ SequenceFlow - + @@ -53,17 +53,17 @@ - - - - + + + + - - + + @@ -74,18 +74,18 @@ - + - + - - + + @@ -97,8 +97,8 @@ - - + +