diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 24e3b67d..19ec96d1 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -494,6 +494,13 @@ function canDrop(element, target, position) { return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]); } + // disallow dropping data store reference if there is no process to append to + if (is(element, 'bpmn:DataStoreReference') && is(target, 'bpmn:Collaboration')) { + return some(getBusinessObject(target).get('participants'), function(participant) { + return !!participant.get('processRef'); + }); + } + // account for the fact that data associations are always // rendered and moved to top (Process or Collaboration level) // diff --git a/test/spec/features/rules/BpmnRules.collaboration-empty.bpmn b/test/spec/features/rules/BpmnRules.collaboration-empty.bpmn new file mode 100644 index 00000000..ebc7d252 --- /dev/null +++ b/test/spec/features/rules/BpmnRules.collaboration-empty.bpmn @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index a449caf8..1d229d9d 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -123,6 +123,26 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanCreate([task1, task2], 'SequenceFlow', false); })); + + describe('empty pool', function() { + + var testXML = require('./BpmnRules.collaboration-empty.bpmn'); + + beforeEach(bootstrapModeler(testXML, { modules: testModules })); + + + it('should not allow to drop DataStoreReference when there is no process to append to', + inject(function(elementFactory) { + + // given + var dataStoreReference = elementFactory.createShape({ type: 'bpmn:DataStoreReference' }); + + // then + expectCanCreate(dataStoreReference, 'Collaboration', false); + }) + ); + }); + });