fix(modeling): apply DataStoreBehavior in collaboration only

* updating parents of datastores in the root is only
  necessary when deleting a subprocess in a collaboration

Related to camunda/camunda-modeler#823
This commit is contained in:
Philipp Fromme 2018-06-13 13:38:38 +02:00 committed by Nico Rehwaldt
parent c7103d8f07
commit 5cc28d5d55
3 changed files with 37 additions and 6 deletions

View File

@ -132,15 +132,14 @@ export default function DataStoreBehavior(
});
// update data store parents on participant deleted
// update data store parents on participant or subprocess deleted
this.postExecute('shape.delete', function(event) {
var context = event.context,
shape = context.shape,
rootElement;
if (isAny(shape, [ 'bpmn:Participant', 'bpmn:SubProcess' ])) {
rootElement = canvas.getRootElement();
rootElement = canvas.getRootElement();
if (isAny(shape, [ 'bpmn:Participant', 'bpmn:SubProcess' ])
&& is(rootElement, 'bpmn:Collaboration')) {
getDataStores(rootElement)
.filter(function(dataStore) {
return isDescendant(dataStore, shape);

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1pdhhel" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.0-dev">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1pdhhel" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.1">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:dataStoreReference id="DataStoreReference" />
<bpmn:subProcess id="SubProcess" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
@ -11,6 +12,9 @@
<dc:Bounds x="25" y="54" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_18wikk9_di" bpmnElement="SubProcess" isExpanded="true">
<dc:Bounds x="0" y="100" width="350" height="200" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -1,3 +1,5 @@
/* global sinon */
import {
bootstrapModeler,
inject
@ -312,6 +314,32 @@ describe('features/modeling/behavior - data store', function() {
});
describe('process', function() {
var processDiagramXML = require('./DataStoreBehavior.process.bpmn');
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
it('should not update parent on subprocess delete', inject(
function(elementRegistry, eventBus, modeling) {
// given
var spy = sinon.spy();
eventBus.on('commandStack.dataStore.updateContainment.execute', spy);
var subProcessElement = elementRegistry.get('SubProcess');
// when
modeling.removeShape(subProcessElement);
// then
expect(spy).to.not.have.been.called;
}
));
});
describe('collaboration', function() {
describe('update parent on participant removed', function() {