From 80d62b9873ea9180f2c4ccda2b3112ebb0d28106 Mon Sep 17 00:00:00 2001 From: Vladimirs Katusenoks Date: Fri, 20 May 2016 12:40:15 +0200 Subject: [PATCH] fix(paste): set correct parent on data associations Closes camunda/camunda-modeler#296 --- lib/features/copy-paste/BpmnCopyPaste.js | 24 +++++--- .../copy-paste/data-associations.bpmn | 61 +++++++++++++++++++ .../features/copy-paste/BpmnCopyPasteSpec.js | 19 +++++- 3 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/bpmn/features/copy-paste/data-associations.bpmn diff --git a/lib/features/copy-paste/BpmnCopyPaste.js b/lib/features/copy-paste/BpmnCopyPaste.js index 9c00174c..bb907b72 100644 --- a/lib/features/copy-paste/BpmnCopyPaste.js +++ b/lib/features/copy-paste/BpmnCopyPaste.js @@ -86,28 +86,34 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv var descriptor = context.descriptor, createdElements = context.createdElements, parent = descriptor.parent, - businessObject, eventDefinitions, newEventDefinition, rootElement, - conditionExpression, loopCharacteristics, - source, target, canConnect; + rootElement = canvas.getRootElement(), + businessObject, + eventDefinitions, + newEventDefinition, + conditionExpression, + loopCharacteristics, + source, + target, + canConnect; if (descriptor.type === 'label') { return; } if (is(parent, 'bpmn:Process')) { - rootElement = canvas.getRootElement(); - descriptor.parent = is(rootElement, 'bpmn:Collaboration') ? rootElement : parent; } + if (descriptor.type === 'bpmn:DataOutputAssociation' || + descriptor.type === 'bpmn:DataInputAssociation' || + descriptor.type === 'bpmn:MessageFlow') { + descriptor.parent = rootElement; + } + if (is(parent, 'bpmn:Lane')) { descriptor.parent = parent.parent; } - if (descriptor.type === 'bpmn:MessageFlow') { - descriptor.parent = canvas.getRootElement(); - } - // make sure that the correct type of connection is created if (descriptor.waypoints) { source = createdElements[descriptor.source]; diff --git a/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn b/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn new file mode 100644 index 00000000..c5a7a7fc --- /dev/null +++ b/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn @@ -0,0 +1,61 @@ + + + + + + + + + + DataStoreReference_1muhdww + + + + + + + + + + DataStoreReference_0q26vzn + Property_0l7g57i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js index 51fed13c..0e45af4e 100644 --- a/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +++ b/test/spec/features/copy-paste/BpmnCopyPasteSpec.js @@ -22,7 +22,8 @@ describe('features/copy-paste', function() { var basicXML = require('../../../fixtures/bpmn/features/copy-paste/basic.bpmn'), collaborationXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration.bpmn'), - collaborationMultipleXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn'); + collaborationMultipleXML = require('../../../fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn'), + collaborationAssociations = require('../../../fixtures/bpmn/features/copy-paste/data-associations.bpmn'); function integrationTest(ids) { @@ -435,6 +436,22 @@ describe('features/copy-paste', function() { }); + + describe('data associations', function() { + + beforeEach(bootstrapModeler(collaborationAssociations, { modules: testModules })); + + + describe('integration', function() { + + it('participant with OutputDataAssociation', inject(integrationTest([ 'Participant_Output' ]))); + + it('participant with InputDataAssociation', inject(integrationTest([ 'Participant_Input' ]))); + + }); + + }); + });