fix(modeling): disallow inserting on incoming/outgoing connection
Closes #836
This commit is contained in:
parent
6d9b04a5f1
commit
249ea6a3ea
|
@ -811,6 +811,11 @@ function canInsert(shape, flow, position) {
|
||||||
shape = shape[0];
|
shape = shape[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flow.source === shape ||
|
||||||
|
flow.target === shape) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// return true if we can drop on the
|
// return true if we can drop on the
|
||||||
// underlying flow parent
|
// underlying flow parent
|
||||||
//
|
//
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="http://bpmn.io" exporterVersion="0.10.1">
|
||||||
|
<process id="Process_1" isExecutable="false">
|
||||||
|
<startEvent id="START" name="START">
|
||||||
|
<outgoing>S1</outgoing>
|
||||||
|
<outgoing>S2</outgoing>
|
||||||
|
</startEvent>
|
||||||
|
<sequenceFlow id="S1" name="S1" sourceRef="START" targetRef="END" />
|
||||||
|
<endEvent id="END" name="END">
|
||||||
|
<incoming>S1</incoming>
|
||||||
|
</endEvent>
|
||||||
|
<exclusiveGateway id="GATEWAY" name="GATEWAY">
|
||||||
|
<incoming>S2</incoming>
|
||||||
|
</exclusiveGateway>
|
||||||
|
<sequenceFlow id="S2" name="S2" sourceRef="START" targetRef="GATEWAY" />
|
||||||
|
</process>
|
||||||
|
<bpmndi:BPMNDiagram id="BpmnDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Process_1">
|
||||||
|
<bpmndi:BPMNShape id="START_di" bpmnElement="START">
|
||||||
|
<omgdc:Bounds x="254" y="174" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<omgdc:Bounds x="254" y="144" width="36" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="S1_di" bpmnElement="S1">
|
||||||
|
<omgdi:waypoint x="290" y="192" />
|
||||||
|
<omgdi:waypoint x="497" y="192" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<omgdc:Bounds x="387" y="174" width="13" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="END_di" bpmnElement="END">
|
||||||
|
<omgdc:Bounds x="497" y="174" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<omgdc:Bounds x="503" y="217" width="24" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="GATEWAY_di" bpmnElement="GATEWAY" isMarkerVisible="true">
|
||||||
|
<omgdc:Bounds x="364" y="281" width="50" height="50" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<omgdc:Bounds x="362" y="338" width="54" height="27" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="S2_di" bpmnElement="S2">
|
||||||
|
<omgdi:waypoint x="272" y="210" />
|
||||||
|
<omgdi:waypoint x="272" y="306" />
|
||||||
|
<omgdi:waypoint x="364" y="306" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<omgdc:Bounds x="281" y="255" width="13" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</definitions>
|
|
@ -6,7 +6,8 @@ import {
|
||||||
import {
|
import {
|
||||||
expectCanConnect,
|
expectCanConnect,
|
||||||
expectCanDrop,
|
expectCanDrop,
|
||||||
expectCanMove
|
expectCanMove,
|
||||||
|
expectCanInsert
|
||||||
} from './Helper';
|
} from './Helper';
|
||||||
|
|
||||||
import modelingModule from 'lib/features/modeling';
|
import modelingModule from 'lib/features/modeling';
|
||||||
|
@ -1602,4 +1603,26 @@ describe('features/modeling/rules - BpmnRules', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('insert', function() {
|
||||||
|
|
||||||
|
var testXML = require('./BpmnRules.insert.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
it('insert END -> S1', function() {
|
||||||
|
expectCanInsert('END', 'S1', false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('insert START -> S1', function() {
|
||||||
|
expectCanInsert('START', 'S1', false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('insert GATEWAY -> S1', function() {
|
||||||
|
expectCanInsert('GATEWAY', 'S1', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,6 +55,25 @@ export function expectCanDrop(element, target, expectedResult) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function expectCanInsert(element, target, expectedResult) {
|
||||||
|
|
||||||
|
var result;
|
||||||
|
|
||||||
|
getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
|
element = elementRegistry.get(element);
|
||||||
|
target = elementRegistry.get(target);
|
||||||
|
|
||||||
|
expect(element).to.exist;
|
||||||
|
expect(target).to.exist;
|
||||||
|
|
||||||
|
result = bpmnRules.canInsert(element, target);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).to.eql(expectedResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function expectCanMove(elements, target, rules) {
|
export function expectCanMove(elements, target, rules) {
|
||||||
|
|
||||||
var results = {};
|
var results = {};
|
||||||
|
|
Loading…
Reference in New Issue