From 8c49cb679b4310ec3f5df198141e05b8bf7b710a Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Thu, 28 Mar 2019 20:46:00 +0100 Subject: [PATCH] fix(modeling): properly handle DataInput / DataOutput move Closes #961 --- lib/features/modeling/BpmnUpdater.js | 8 ++ .../MoveElements.data-input-output.bpmn | 74 +++++++++++++++++++ .../features/modeling/MoveElementsSpec.js | 59 ++++++++++++++- 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 test/spec/features/modeling/MoveElements.data-input-output.bpmn diff --git a/lib/features/modeling/BpmnUpdater.js b/lib/features/modeling/BpmnUpdater.js index 5d774993..5d58ff82 100644 --- a/lib/features/modeling/BpmnUpdater.js +++ b/lib/features/modeling/BpmnUpdater.js @@ -492,6 +492,14 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent, return; } + if (is(businessObject, 'bpmn:DataInput') || is(businessObject, 'bpmn:DataOutput')) { + + // already in correct ioSpecification + if ('ioSpecification' in newParent && newParent.ioSpecification === businessObject.$parent) { + return; + } + } + if (is(businessObject, 'bpmn:Lane')) { if (newParent) { diff --git a/test/spec/features/modeling/MoveElements.data-input-output.bpmn b/test/spec/features/modeling/MoveElements.data-input-output.bpmn new file mode 100644 index 00000000..2c04097b --- /dev/null +++ b/test/spec/features/modeling/MoveElements.data-input-output.bpmn @@ -0,0 +1,74 @@ + + + + + + + DataInput + + + DataOutput + + + + + + + + _9628422b-85a6-4857-8c14-7289b9fd9a8a + + + _29b8c649-e2a0-4dd3-804b-567e8cc71718 + + + + DataInput + _9628422b-85a6-4857-8c14-7289b9fd9a8a + + + _29b8c649-e2a0-4dd3-804b-567e8cc71718 + DataOutput + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/features/modeling/MoveElementsSpec.js b/test/spec/features/modeling/MoveElementsSpec.js index b8adc135..d3ab8e58 100644 --- a/test/spec/features/modeling/MoveElementsSpec.js +++ b/test/spec/features/modeling/MoveElementsSpec.js @@ -9,7 +9,7 @@ import coreModule from 'lib/core'; describe('features/modeling - move elements', function() { - describe('should keep flow parent', function() { + describe('flow parent', function() { var diagramXML = require('./MoveElements.flow-collaboration.bpmn'); @@ -21,7 +21,7 @@ describe('features/modeling - move elements', function() { })); - it('when moving shapes', inject(function(elementRegistry, modeling, bpmnFactory) { + it('should keep when moving shapes', inject(function(elementRegistry, modeling, bpmnFactory) { // given var connectionSequenceFlow = elementRegistry.get('SequenceFlow'), @@ -44,7 +44,7 @@ describe('features/modeling - move elements', function() { })); - it('when moving shapes with flow', inject(function(elementRegistry, modeling, bpmnFactory) { + it('should keep when moving shapes with flow', inject(function(elementRegistry, modeling, bpmnFactory) { // given var connectionSequenceFlow = elementRegistry.get('SequenceFlow'), @@ -69,7 +69,7 @@ describe('features/modeling - move elements', function() { }); - describe('should move boundary connection with tasks', function() { + describe('boundary connection with tasks', function() { var diagramXML = require('./MoveElements.boundary-connection.bpmn'); @@ -105,6 +105,57 @@ describe('features/modeling - move elements', function() { }); + + describe('data input / data output', function() { + + var diagramXML = require('./MoveElements.data-input-output.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); + + + it('should move', inject(function(elementRegistry, modeling) { + + // given + var dataInput = elementRegistry.get('DataInput'); + var dataOutput = elementRegistry.get('DataOutput'); + + var elements = [ + dataInput, + dataOutput, + elementRegistry.get('Task') + ]; + + // when + modeling.moveElements( + elements, + { x: -10, y: -10 } + ); + + // then + expect(dataOutput).to.have.bounds({ + x: 275, + y: 140, + width: 34, + height: 40 + }); + + expect(dataInput).to.have.bounds({ + x: 90, + y: 90, + width: 34, + height: 40 + }); + })); + + }); + + + });