From d90f048e8c55cffdbd02fb2c0450e73038cf3941 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 22 Dec 2017 11:08:49 +0100 Subject: [PATCH] chore(layout): support { source, target } hints in BpmnLayouter Closes #743 --- lib/features/modeling/BpmnLayouter.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/features/modeling/BpmnLayouter.js b/lib/features/modeling/BpmnLayouter.js index 5f6aaa30..5a101803 100644 --- a/lib/features/modeling/BpmnLayouter.js +++ b/lib/features/modeling/BpmnLayouter.js @@ -31,8 +31,8 @@ inherits(BpmnLayouter, BaseLayouter); BpmnLayouter.prototype.layoutConnection = function(connection, hints) { hints = hints || {}; - var source = connection.source, - target = connection.target, + var source = hints.source || connection.source, + target = hints.target || connection.target, waypoints = connection.waypoints, start = hints.connectionStart, end = hints.connectionEnd; @@ -54,7 +54,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) { if (is(connection, 'bpmn:Association') || is(connection, 'bpmn:DataAssociation')) { - if (waypoints && !isCompensationAssociation(connection)) { + if (waypoints && !isCompensationAssociation(source, target)) { return [].concat([ start ], waypoints.slice(1, -1), [ end ]); } } @@ -75,7 +75,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) { // (3) loops from / to the same element // if (is(connection, 'bpmn:SequenceFlow') || - isCompensationAssociation(connection)) { + isCompensationAssociation(source, target)) { if (source === target) { manhattanOptions = { @@ -189,11 +189,7 @@ function getConnectionDocking(point, shape) { return point ? (point.original || point) : getMid(shape); } -function isCompensationAssociation(connection) { - - var source = connection.source, - target = connection.target; - +function isCompensationAssociation(source, target) { return is(target, 'bpmn:Activity') && is(source, 'bpmn:BoundaryEvent') && target.businessObject.isForCompensation;