Merge branch 'master' into develop

This commit is contained in:
Philipp Fromme 2019-09-24 14:41:03 +02:00
commit 5736cfe794
2 changed files with 44 additions and 3 deletions

View File

@ -90,17 +90,26 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
var references; var references;
function resolveReferences(descriptor) { function resolveReferences(descriptor, cache) {
var businessObject = getBusinessObject(descriptor); var businessObject = getBusinessObject(descriptor);
// default sequence flows // default sequence flows
if (descriptor.default) { if (descriptor.default) {
// relationship cannot be resolved immediately
references[ descriptor.default ] = { references[ descriptor.default ] = {
element: businessObject, element: businessObject,
property: 'default' 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) { references = omit(references, reduce(references, function(array, reference, key) {
var element = reference.element, var element = reference.element,
property = reference.property; property = reference.property;
@ -140,7 +149,7 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
); );
// resolve references e.g. default sequence flow // resolve references e.g. default sequence flow
resolveReferences(descriptor); resolveReferences(descriptor, cache);
copyProperties(descriptor, newBusinessObject, [ copyProperties(descriptor, newBusinessObject, [
'isExpanded', 'isExpanded',
@ -163,4 +172,4 @@ BpmnCopyPaste.$inject = [
function isLabel(element) { function isLabel(element) {
return !!element.labelTarget; return !!element.labelTarget;
} }

View File

@ -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', it('should copy loop characteristics porperties',
inject(function(canvas, copyPaste, elementRegistry, modeling) { inject(function(canvas, copyPaste, elementRegistry, modeling) {