fix(modeling/copy-paste): copy referenced message if not present

Related to https://github.com/camunda/camunda-modeler/issues/1639
This commit is contained in:
Maciej Barelkowski
2020-01-30 17:07:03 +01:00
committed by fake-join[bot]
parent 4bafbe5d8b
commit dc5a566e10
2 changed files with 26 additions and 6 deletions

View File

@ -28,7 +28,9 @@ var LOW_PRIORITY = 500;
* Add referenced root elements (error, escalation, message, signal) if they don't exist.
* Copy referenced root elements on copy & paste.
*/
export default function RootElementReferenceBehavior(bpmnjs, eventBus, injector) {
export default function RootElementReferenceBehavior(
bpmnjs, eventBus, injector, moddleCopy, bpmnFactory
) {
injector.invoke(CommandInterceptor, this);
function hasRootElement(rootElement) {
@ -140,6 +142,13 @@ export default function RootElementReferenceBehavior(bpmnjs, eventBus, injector)
return;
}
if (!hasRootElement(referencedRootElement)) {
referencedRootElement = moddleCopy.copyElement(
referencedRootElement,
bpmnFactory.create(referencedRootElement.$type)
);
}
eventDefinition.set(getRootElementReferencePropertyName(eventDefinition), referencedRootElement);
});
}
@ -147,7 +156,9 @@ export default function RootElementReferenceBehavior(bpmnjs, eventBus, injector)
RootElementReferenceBehavior.$inject = [
'bpmnjs',
'eventBus',
'injector'
'injector',
'moddleCopy',
'bpmnFactory'
];
inherits(RootElementReferenceBehavior, CommandInterceptor);