Skip to content

Commit

Permalink
feat(bpmn-layouter): layout loops
Browse files Browse the repository at this point in the history
Closes #824
  • Loading branch information
philippfromme committed Jul 13, 2018
1 parent b3c05b6 commit 289052f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
6 changes: 6 additions & 0 deletions lib/features/modeling/BpmnLayouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
}
}

if (source === target) {
manhattanOptions = {
preferredLayouts: [ 'r:b' ]
};
}

if (manhattanOptions) {

manhattanOptions = assign(manhattanOptions, hints);
Expand Down
9 changes: 0 additions & 9 deletions lib/features/rules/BpmnRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
21 changes: 20 additions & 1 deletion test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -52,6 +51,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([
{ original: { x: 332, y: 220 }, x: 382, y: 220 },
{ x: 402, y: 220 },
{ x: 402, y: 280 },
{ x: 332, y: 280 },
{ original: { x: 332, y: 220 }, x: 332, y: 260 }
]);
});

});


describe('gateway layout', function() {

it('should layout v:h after Gateway', inject(function() {
Expand Down
11 changes: 11 additions & 0 deletions test/spec/features/rules/BpmnRulesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}));

});


Expand Down

0 comments on commit 289052f

Please sign in to comment.