diff --git a/lib/features/replace-preview/BpmnReplacePreview.js b/lib/features/replace-preview/BpmnReplacePreview.js
index 8ae9cb31..af7060bd 100644
--- a/lib/features/replace-preview/BpmnReplacePreview.js
+++ b/lib/features/replace-preview/BpmnReplacePreview.js
@@ -107,7 +107,7 @@ export default function BpmnReplacePreview(
context.visualReplacements = {};
}
- if (canExecute.replacements) {
+ if (canExecute && canExecute.replacements) {
replaceVisual(context);
} else {
restoreVisual(context);
diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js
index 4f7f8f10..7cf85146 100644
--- a/lib/features/rules/BpmnRules.js
+++ b/lib/features/rules/BpmnRules.js
@@ -123,10 +123,25 @@ BpmnRules.prototype.init = function() {
shapes = context.shapes,
position = context.position;
- return canAttach(shapes, target, null, position) ||
- canReplace(shapes, target, position) ||
- canMove(shapes, target, position) ||
- canInsert(shapes, target, position);
+ var attach = canAttach(shapes, target, null, position);
+
+ if (attach || attach === null) {
+ return attach;
+ }
+
+ var replace = canReplace(shapes, target, position);
+
+ if (replace || replace === null) {
+ return replace;
+ }
+
+ var move = canMove(shapes, target, position);
+
+ if (move || move === null) {
+ return move;
+ }
+
+ return canInsert(shapes, target, position);
});
this.addRule('shape.create', function(context) {
@@ -451,7 +466,7 @@ function canDrop(element, target, position) {
// can move labels everywhere
if (isLabel(element)) {
- return true;
+ return null;
}
// disallow to create elements on collapsed pools
@@ -751,9 +766,21 @@ function canMove(elements, target) {
return true;
}
- return elements.every(function(element) {
- return canDrop(element, target);
- });
+ var move,
+ currentMove;
+
+ for (var i = 0; i < elements.length; i++) {
+
+ currentMove = canDrop(elements[i], target);
+
+ if (currentMove === false) {
+ return false;
+ }
+
+ move = move || currentMove;
+ }
+
+ return move;
}
function canCreate(shape, target, source, position) {
diff --git a/test/spec/features/rules/BpmnRules.collaboration.bpmn b/test/spec/features/rules/BpmnRules.collaboration.bpmn
index 4c1b2470..b7406d1a 100644
--- a/test/spec/features/rules/BpmnRules.collaboration.bpmn
+++ b/test/spec/features/rules/BpmnRules.collaboration.bpmn
@@ -7,6 +7,7 @@
+
@@ -170,6 +171,9 @@
+
+
+
diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js
index f92d3b1c..a69d6358 100644
--- a/test/spec/features/rules/BpmnRulesSpec.js
+++ b/test/spec/features/rules/BpmnRulesSpec.js
@@ -1015,33 +1015,38 @@ describe('features/modeling/rules - BpmnRules', function() {
it('-> MessageFlow', function() {
- expectCanDrop(label, 'MessageFlow_labeled', true);
+ expectCanDrop(label, 'MessageFlow_labeled', null);
});
it('-> CollapsedParticipant', function() {
- expectCanDrop(label, 'CollapsedParticipant', true);
+ expectCanDrop(label, 'CollapsedParticipant', null);
});
it('-> Collaboration', function() {
// then
- expectCanDrop(label, 'Collaboration', true);
+ expectCanDrop(label, 'Collaboration', null);
});
it('-> Task_in_SubProcess', function() {
- expectCanDrop(label, 'Task_in_SubProcess', true);
+ expectCanDrop(label, 'Task_in_SubProcess', null);
});
it('-> SequenceFlow', function() {
- expectCanDrop(label, 'SequenceFlow', true);
+ expectCanDrop(label, 'SequenceFlow', null);
});
it('-> DataOutputAssociation', function() {
- expectCanDrop(label, 'DataOutputAssociation', true);
+ expectCanDrop(label, 'DataOutputAssociation', null);
+ });
+
+
+ it('-> Group', function() {
+ expectCanDrop(label, 'Group', null);
});
});