chore(bpmn-rules): add function to check for same parent

This commit is contained in:
pedesen 2015-07-30 10:32:17 +02:00
parent 8e4f480868
commit 02416de290
1 changed files with 11 additions and 4 deletions

View File

@ -378,10 +378,7 @@ function canAttach(elements, target, source, position) {
function canMove(elements, target) { function canMove(elements, target) {
// only move if they have the same parent // only move if they have the same parent
var sameParent = size(groupBy(elements, function(s) { return s.parent && s.parent.id; })) === 1; if (!haveSameParent(elements)) {
// Remove attachers that already have their host in the lis
if (!sameParent) {
return false; return false;
} }
@ -501,3 +498,13 @@ function canConnectBoundaryEvent(source, target) {
return false; return false;
} }
/**
* Returns true if all elements have the same parent
*
* @param {Array<djs.model.Base>} elements
* @return {Boolean}
*/
function haveSameParent(elements) {
return size(groupBy(elements, function(e) { return e.parent && e.parent.id; })) === 1;
}