fix(rules): disallow creating DataStoreReference if process is missing
Closes #1456
This commit is contained in:
parent
e0c4dea90d
commit
7f1c0be591
|
@ -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)
|
||||
//
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn2:definitions xmlns:bpmn2="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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_biH3sOTeEeS2YerRfpjPrw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
||||
<bpmn2:collaboration id="Collaboration">
|
||||
<bpmn2:participant id="Participant" name="Pool"/>
|
||||
</bpmn2:collaboration>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant" isHorizontal="true">
|
||||
<dc:Bounds x="72" y="48" width="706" height="266" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn2:definitions>
|
|
@ -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);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue