Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 24, 2019
2 parents 5123283 + d55e3af commit 5736cfe
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 @@ -90,17 +90,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 @@ -140,7 +149,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 @@ -163,4 +172,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 @@ -169,6 +169,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 5736cfe

Please sign in to comment.