diff --git a/lib/features/distribute-elements/BpmnDistributeElements.js b/lib/features/distribute-elements/BpmnDistributeElements.js index 4bb66a8d..0a0a63d4 100644 --- a/lib/features/distribute-elements/BpmnDistributeElements.js +++ b/lib/features/distribute-elements/BpmnDistributeElements.js @@ -13,14 +13,15 @@ function BpmnDistributeElements(distributeElements) { distributeElements.registerFilter(function(elements) { return filter(elements, function(element) { var cannotDistribute = isAny(element, [ - 'bpmn:SequenceFlow', - 'bpmn:MessageFlow', + 'bpmn:Association', + 'bpmn:BoundaryEvent', 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation', - 'bpmn:Association', - 'bpmn:TextAnnotation', + 'bpmn:Lane', + 'bpmn:MessageFlow', 'bpmn:Participant', - 'bpmn:Lane' + 'bpmn:SequenceFlow', + 'bpmn:TextAnnotation' ]); return !(element.labelTarget || cannotDistribute); diff --git a/test/fixtures/bpmn/distribute-elements-filtering.bpmn b/test/fixtures/bpmn/distribute-elements-filtering.bpmn new file mode 100644 index 00000000..111671e2 --- /dev/null +++ b/test/fixtures/bpmn/distribute-elements-filtering.bpmn @@ -0,0 +1,58 @@ + + + + + SequenceFlow_0vrvkcp + + + SequenceFlow_0vrvkcp + + + + SequenceFlow_1jet52k + + + SequenceFlow_1jet52k + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js b/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js index dd940b8f..5e9f6090 100644 --- a/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js +++ b/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js @@ -16,13 +16,14 @@ function last(arr) { describe('features/distribute-elements', function() { var testModules = [ bpmnDistributeElements, modelingModule, coreModule ]; - var basicXML = require('../../../fixtures/bpmn/distribute-elements.bpmn'); - - beforeEach(bootstrapModeler(basicXML, { modules: testModules })); describe('basics', function() { + var basicXML = require('../../../fixtures/bpmn/distribute-elements.bpmn'); + + beforeEach(bootstrapModeler(basicXML, { modules: testModules })); + var elements; beforeEach(inject(function(elementRegistry, canvas) { @@ -33,6 +34,7 @@ describe('features/distribute-elements', function() { it('should align horizontally', inject(function(distributeElements) { + // when var rangeGroups = distributeElements.trigger(elements, 'horizontal'), margin = rangeGroups[1].range.min - rangeGroups[0].range.max; @@ -49,10 +51,12 @@ describe('features/distribute-elements', function() { expect(last(rangeGroups).range).to.eql({ min: 1195, max: 1221 }); + })); it('should align vertically', inject(function(distributeElements) { + // when var rangeGroups = distributeElements.trigger(elements, 'vertical'), margin = rangeGroups[1].range.min - rangeGroups[0].range.max; @@ -69,6 +73,39 @@ describe('features/distribute-elements', function() { expect(last(rangeGroups).range).to.eql({ min: 373, max: 413 }); + + })); + + }); + + describe('filtering elements', function() { + + var xml = require('../../../fixtures/bpmn/distribute-elements-filtering.bpmn'); + + beforeEach(bootstrapModeler(xml, { modules: testModules })); + + var elements; + + beforeEach(inject(function(elementRegistry, canvas) { + elements = elementRegistry.filter(function(element) { + return element.parent; + }); + })); + + + it('should not distribute boundary events', inject(function(distributeElements, elementRegistry) { + + // given + var boundaryEvent = elementRegistry.get('BoundaryEvent_1'); + + // when + var rangeGroups = distributeElements.trigger(elements, 'horizontal'); + + // then + expect(rangeGroups).to.have.length(3); + + expect(rangeGroups[1].elements).to.not.include(boundaryEvent); + })); });