diff --git a/lib/features/modeling/BpmnLayouter.js b/lib/features/modeling/BpmnLayouter.js index 9c3cf900..ee5030ba 100644 --- a/lib/features/modeling/BpmnLayouter.js +++ b/lib/features/modeling/BpmnLayouter.js @@ -105,10 +105,17 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) { // // (1) outgoing of BoundaryEvents -> layout based on attach orientation and target orientation // (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming) + // (3) loops from / to the same element // if (is(connection, 'bpmn:SequenceFlow') || isCompensationAssociation(connection)) { + if (source === target) { + manhattanOptions = { + preferredLayouts: [ 'b:l' ] + }; + } else + if (is(source, 'bpmn:BoundaryEvent')) { manhattanOptions = { @@ -136,6 +143,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) { preferredLayouts: [ 'h:h' ] }; } + } if (manhattanOptions) { diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index ed802cad..6a28d2bd 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -378,15 +378,6 @@ function canConnect(source, target, connection) { return null; } - // See https://github.com/bpmn-io/bpmn-js/issues/178 - // as a workround we disallow connections with same - // target and source element. - // This rule must be removed if a auto layout for this - // connections is implemented. - if (isSame(source, target)) { - return false; - } - if (!is(connection, 'bpmn:DataAssociation')) { if (canConnectMessageFlow(source, target)) { diff --git a/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js b/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js index 018ede39..493382f9 100644 --- a/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js +++ b/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js @@ -18,7 +18,6 @@ import coreModule from 'lib/core'; describe('features/modeling - layout', function() { - describe.skip('overall experience, flow elements', function() { var diagramXML = require('./LayoutSequenceFlowSpec.flowElements.bpmn'); @@ -177,6 +176,26 @@ describe('features/modeling - layout', function() { beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); + describe('loops', function() { + + it('should layout loop', function() { + + // when + var connection = connect('Task_1', 'Task_1'); + + // then + expect(connection).to.have.waypoints([ + { x: 332, y: 260 }, + { x: 332, y: 280 }, + { x: 262, y: 280 }, + { x: 262, y: 220 }, + { x: 282, y: 220 } + ]); + }); + + }); + + describe('gateway layout', function() { it('should layout v:h after Gateway', inject(function() { diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index 9b7157e3..a8c64d56 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -328,6 +328,17 @@ describe('features/modeling/rules - BpmnRules', function() { }); })); + + it('connect Task -> Task', inject(function() { + + expectCanConnect('Task', 'Task', { + sequenceFlow: true, + messageFlow: false, + association: false, + dataAssociation: false + }); + })); + });