chore(copy-paste): temporarily prevent consecutive paste

This prevents users from creating invalid
models due to IDs not properly being
generated on consecutive paste (#686).

Closes #688.
This commit is contained in:
Nico Rehwaldt 2017-05-19 12:55:46 +02:00
parent 4a83d7a060
commit 8e55edd80f
2 changed files with 44 additions and 2 deletions

View File

@ -30,7 +30,9 @@ function removeProperties(element, properties) {
});
}
function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canvas, bpmnRules) {
function BpmnCopyPaste(
bpmnFactory, eventBus, copyPaste,
clipboard, canvas, bpmnRules) {
var helper = new ModelCloneHelper(eventBus);
@ -138,6 +140,14 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
'triggeredByEvent'
]);
});
eventBus.on('commandStack.elements.paste.postExecuted', function() {
// temporarily disable multi paste until #686
// is addressed
clipboard.clear();
});
}
@ -146,7 +156,6 @@ BpmnCopyPaste.$inject = [
'eventBus',
'copyPaste',
'clipboard',
'moddle',
'canvas',
'bpmnRules'
];

View File

@ -58,6 +58,38 @@ describe('features/copy-paste', function() {
});
it('should forbid multi paste', inject(
function(elementRegistry, canvas, copyPaste) {
// given
var element = elementRegistry.get('SubProcess_1kd6ist'),
rootElement = canvas.getRootElement();
// when
copyPaste.copy(element);
copyPaste.paste({
element: rootElement,
point: {
x: 600,
y: 100
}
});
copyPaste.paste({
element: rootElement,
point: {
x: 600,
y: 275
}
});
// then
// pasted was only once
expect(rootElement.children).to.have.length(2);
}
));
describe('integration', function() {
it('should retain label\'s relative position',
@ -489,6 +521,7 @@ describe('features/copy-paste', function() {
it('multiple participants', inject(integrationTest([ 'Participant_0pgdgt4', 'Participant_1id96b4' ])));
it('multiple participants', inject(integrationTest([ 'Participant_0pgdgt4', 'Participant_1id96b4' ])));
});
});