From 30e3fdd81c5a5a4fa8c99e86a2f3212f9d717f41 Mon Sep 17 00:00:00 2001 From: Ricardo Matias Date: Tue, 3 May 2016 16:49:10 +0200 Subject: [PATCH] fix(copy-paste): allow pasting of elements onto lanes Closes #532 --- .../modeling/behavior/CopyPasteBehavior.js | 4 +-- .../features/copy-paste/BpmnCopyPasteSpec.js | 29 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/features/modeling/behavior/CopyPasteBehavior.js b/lib/features/modeling/behavior/CopyPasteBehavior.js index 949a7e66..e8bcb768 100644 --- a/lib/features/modeling/behavior/CopyPasteBehavior.js +++ b/lib/features/modeling/behavior/CopyPasteBehavior.js @@ -24,9 +24,9 @@ function CopyPasteBehavior(eventBus, modeling, canvas) { if (is(topParent, 'bpmn:Lane')) { do { // unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer) - topParent = context.topParent = topParent.parent.parent; + topParent = context.topParent = topParent.parent; - } while (is(topParent, 'bpmn:Lane')); + } while (is(topParent, 'bpmn:Lane') || !is(topParent, 'bpmn:Participant')); } }, true); diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index 94b9ea6a..7bceb741 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -125,7 +125,7 @@ describe('features/copy-paste', function() { expectCollection(initialContext.type, currentContext.type, true); expectCollection(initialContext.ids, currentContext.ids, false); }; - }; + } describe('basic diagram', function() { @@ -407,7 +407,32 @@ describe('features/copy-paste', function() { describe('basics', function() { - it('pasting on lane', inject(function(elementRegistry, copyPaste) { + it('pasting on a lane', inject(function(elementRegistry, copyPaste) { + // given + var lane = elementRegistry.get('Lane_0aws6ii'), + task = elementRegistry.get('Task_1pamrp2'), + participant = elementRegistry.get('Participant_1id96b4'); + + // when + copyPaste.copy(task); + + copyPaste.paste({ + element: lane, + point: { + x: 400, + y: 450 + } + }); + + // then + expect(lane.children).to.be.empty; + expect(lane.businessObject.flowNodeRef).to.have.length(2); + + expect(participant.children).to.have.length(10); + })); + + + it('pasting on a nested lane', inject(function(elementRegistry, copyPaste) { // given var lane = elementRegistry.get('Lane_1yo0kyz'), task = elementRegistry.get('Task_0n0k2nj'),