Skip to content

Commit

Permalink
fix(copy-paste): copy attacher properties
Browse files Browse the repository at this point in the history
Closes #1190
  • Loading branch information
Oguz Eroglu authored and fake-join[bot] committed Sep 24, 2019
1 parent f177a46 commit d55e3af
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/features/copy-paste/BpmnCopyPaste.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,26 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {

var references;

function resolveReferences(descriptor) {
function resolveReferences(descriptor, cache) {
var businessObject = getBusinessObject(descriptor);

// default sequence flows
if (descriptor.default) {

// relationship cannot be resolved immediately
references[ descriptor.default ] = {
element: businessObject,
property: 'default'
};
}

// boundary events
if (descriptor.host) {

// relationship can be resolved immediately
getBusinessObject(descriptor).attachedToRef = getBusinessObject(cache[ descriptor.host ]);
}

references = omit(references, reduce(references, function(array, reference, key) {
var element = reference.element,
property = reference.property;
Expand Down Expand Up @@ -134,7 +143,7 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
);

// resolve references e.g. default sequence flow
resolveReferences(descriptor);
resolveReferences(descriptor, cache);

copyProperties(descriptor, newBusinessObject, [
'isExpanded',
Expand All @@ -157,4 +166,4 @@ BpmnCopyPaste.$inject = [

function isLabel(element) {
return !!element.labelTarget;
}
}
32 changes: 32 additions & 0 deletions test/spec/features/copy-paste/BpmnCopyPasteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,38 @@ describe('features/copy-paste', function() {
);


it('should copy attacher properties', inject(function(canvas, copyPaste, elementRegistry) {

// given
var task = elementRegistry.get('Task_1'),
boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
rootElement = canvas.getRootElement();

// when
copyPaste.copy([ task, boundaryEvent ]);

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

// then
task = find(elements, function(element) {
return is(element, 'bpmn:Task');
});

boundaryEvent = find(elements, function(element) {
return is(element, 'bpmn:BoundaryEvent');
});

// then
expect(getBusinessObject(boundaryEvent).attachedToRef).to.equal(getBusinessObject(task));
}));


it('should copy loop characteristics porperties',
inject(function(canvas, copyPaste, elementRegistry, modeling) {

Expand Down

0 comments on commit d55e3af

Please sign in to comment.