This commit is contained in:
Maciej Barelkowski 2021-10-15 16:59:34 +02:00
parent 973ac6e35a
commit 71416249d5
1 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import inherits from 'inherits';
import { forEach } from 'min-dash';
import { forEach, reduce } from 'min-dash';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
@ -30,10 +30,14 @@ export default function ReplaceElementBehaviour(
target = context.parent,
elements = context.elements;
var canReplace = bpmnRules.canReplace(elements, target);
var elementReplacements = reduce(elements, function(replacements, element) {
var canReplace = bpmnRules.canReplace([ element ], element.host || element.parent || target);
if (canReplace) {
this.replaceElements(elements, canReplace.replacements);
return canReplace ? replacements.concat(canReplace.replacements) : replacements;
}, []);
if (elementReplacements.length) {
this.replaceElements(elements, elementReplacements);
}
}, this);