Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for replacement using actual target #1699

Merged
merged 1 commit into from Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/features/modeling/behavior/ReplaceElementBehaviour.js
@@ -1,6 +1,6 @@
import inherits from 'inherits-browser';

import { forEach } from 'min-dash';
import { forEach, reduce } from 'min-dash';

import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -7,8 +7,12 @@ import replacePreviewModule from 'lib/features/replace-preview';
import modelingModule from 'lib/features/modeling';
import moveModule from 'diagram-js/lib/features/move';
import coreModule from 'lib/core';
import copyPasteModule from 'lib/features/copy-paste';

import { is } from 'lib/util/ModelUtil';
import {
getBusinessObject,
is
} from 'lib/util/ModelUtil';

import {
createCanvasEvent as canvasEvent
Expand All @@ -29,7 +33,8 @@ describe('features/modeling - replace element behavior', function() {
replacePreviewModule,
modelingModule,
coreModule,
moveModule
moveModule,
copyPasteModule
];


Expand Down Expand Up @@ -110,6 +115,38 @@ describe('features/modeling - replace element behavior', function() {
})
);


it('should not replace non-interrupting start event after copy paste',
inject(function(canvas, copyPaste, elementRegistry) {

// given
var subProcess = elementRegistry.get('SubProcess_1'),
rootElement = canvas.getRootElement();

// when
copyPaste.copy(subProcess);

var elements = copyPaste.paste({
element: rootElement,
point: {
x: 100,
y: 100
}
});

// then
var startEvents = elements.filter(function(element) {
if (is(element, 'bpmn:StartEvent') && getBusinessObject(element).get('eventDefinitions').length) {
return true;
}
});

startEvents.forEach(function(startEvent) {
expect(getBusinessObject(startEvent).get('isInterrupting')).to.be.false;
});
})
);

});


Expand Down