From 02416de2901fd66e1596fea2f1105d5c8fb15cbd Mon Sep 17 00:00:00 2001 From: pedesen Date: Thu, 30 Jul 2015 10:32:17 +0200 Subject: [PATCH] chore(bpmn-rules): add function to check for same parent --- lib/features/modeling/rules/BpmnRules.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/features/modeling/rules/BpmnRules.js b/lib/features/modeling/rules/BpmnRules.js index 829803a9..e4a4cd98 100644 --- a/lib/features/modeling/rules/BpmnRules.js +++ b/lib/features/modeling/rules/BpmnRules.js @@ -378,10 +378,7 @@ function canAttach(elements, target, source, position) { function canMove(elements, target) { // only move if they have the same parent - var sameParent = size(groupBy(elements, function(s) { return s.parent && s.parent.id; })) === 1; - - // Remove attachers that already have their host in the lis - if (!sameParent) { + if (!haveSameParent(elements)) { return false; } @@ -501,3 +498,13 @@ function canConnectBoundaryEvent(source, target) { return false; } + +/** + * Returns true if all elements have the same parent + * + * @param {Array} elements + * @return {Boolean} + */ +function haveSameParent(elements) { + return size(groupBy(elements, function(e) { return e.parent && e.parent.id; })) === 1; +}