diff --git a/lib/features/copy-paste/BpmnCopyPaste.js b/lib/features/copy-paste/BpmnCopyPaste.js index d0e6fe32..9c00174c 100644 --- a/lib/features/copy-paste/BpmnCopyPaste.js +++ b/lib/features/copy-paste/BpmnCopyPaste.js @@ -100,6 +100,10 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv descriptor.parent = is(rootElement, 'bpmn:Collaboration') ? rootElement : parent; } + if (is(parent, 'bpmn:Lane')) { + descriptor.parent = parent.parent; + } + if (descriptor.type === 'bpmn:MessageFlow') { descriptor.parent = canvas.getRootElement(); } diff --git a/lib/features/modeling/behavior/CopyPasteBehavior.js b/lib/features/modeling/behavior/CopyPasteBehavior.js index e982fe3a..949a7e66 100644 --- a/lib/features/modeling/behavior/CopyPasteBehavior.js +++ b/lib/features/modeling/behavior/CopyPasteBehavior.js @@ -20,6 +20,14 @@ function CopyPasteBehavior(eventBus, modeling, canvas) { if (!topParent.parent) { context.topParent = canvas.getRootElement(); } + + if (is(topParent, 'bpmn:Lane')) { + do { + // unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer) + topParent = context.topParent = topParent.parent.parent; + + } while (is(topParent, 'bpmn:Lane')); + } }, true); this.postExecute('elements.paste', function(context) { diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index a24c9154..26f6ad5c 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -93,10 +93,12 @@ describe('features/copy-paste', function() { commandStack.undo(); commandStack.undo(); + elements = elementRegistry.getAll(); + currentContext = { - type: mapProperty(shapes, 'type'), - ids: mapProperty(shapes, 'id'), - length: shapes.length + type: mapProperty(elements, 'type'), + ids: mapProperty(elements, 'id'), + length: elements.length }; // then @@ -109,10 +111,12 @@ describe('features/copy-paste', function() { commandStack.redo(); commandStack.redo(); + elements = elementRegistry.getAll(); + currentContext = { - type: mapProperty(elementRegistry.getAll(), 'type'), - ids: mapProperty(elementRegistry.getAll(), 'id'), - length: shapes.length + type: mapProperty(elements, 'type'), + ids: mapProperty(elements, 'id'), + length: elements.length }; // then @@ -362,6 +366,35 @@ describe('features/copy-paste', function() { beforeEach(bootstrapModeler(collaborationMultipleXML, { modules: testModules })); + describe('basics', function() { + + it('pasting on lane', inject(function(elementRegistry, copyPaste) { + // given + var lane = elementRegistry.get('Lane_1yo0kyz'), + task = elementRegistry.get('Task_0n0k2nj'), + participant = elementRegistry.get('Participant_0pgdgt4'); + + // when + copyPaste.copy(task); + + copyPaste.paste({ + element: lane, + point: { + x: 200, + y: 75 + } + }); + + // then + expect(lane.children).to.be.empty; + expect(lane.businessObject.flowNodeRef).to.have.length(2); + + expect(lane.parent.children).to.have.length(2); + expect(participant.children).to.have.length(5); + })); + + }); + describe('integration', function() { it('multiple participants', inject(integrationTest([ 'Participant_0pgdgt4', 'Participant_1id96b4' ])));