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 11, 2018
1 parent 504e37a commit 51599e9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions lib/features/modeling/BpmnLayouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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
25 changes: 25 additions & 0 deletions test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ describe('features/modeling - layout', function() {
});


describe('loops', function() {

var diagramXML = require('./LayoutSequenceFlowSpec.flowElements.bpmn');

beforeEach(bootstrapModeler(diagramXML, { modules: Modeler.prototype._modules }));


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('boundary events', function() {

var diagramXML = require('./LayoutSequenceFlowSpec.boundaryEvents.bpmn');
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 51599e9

Please sign in to comment.