fix(copy-paste): allow pasting of elements onto lanes

Closes #532
This commit is contained in:
Ricardo Matias 2016-05-03 16:49:10 +02:00 committed by Nico Rehwaldt
parent 35ca66e48a
commit 30e3fdd81c
2 changed files with 29 additions and 4 deletions

View File

@ -24,9 +24,9 @@ function CopyPasteBehavior(eventBus, modeling, canvas) {
if (is(topParent, 'bpmn:Lane')) { if (is(topParent, 'bpmn:Lane')) {
do { do {
// unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer) // 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); }, true);

View File

@ -125,7 +125,7 @@ describe('features/copy-paste', function() {
expectCollection(initialContext.type, currentContext.type, true); expectCollection(initialContext.type, currentContext.type, true);
expectCollection(initialContext.ids, currentContext.ids, false); expectCollection(initialContext.ids, currentContext.ids, false);
}; };
}; }
describe('basic diagram', function() { describe('basic diagram', function() {
@ -407,7 +407,32 @@ describe('features/copy-paste', function() {
describe('basics', 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 // given
var lane = elementRegistry.get('Lane_1yo0kyz'), var lane = elementRegistry.get('Lane_1yo0kyz'),
task = elementRegistry.get('Task_0n0k2nj'), task = elementRegistry.get('Task_0n0k2nj'),