fix(drop-on-flow): disallow drop on flow label

Closes camunda/camunda-modeler#548
This commit is contained in:
Philipp Fromme 2017-03-10 10:38:29 +01:00 committed by Nico Rehwaldt
parent 497affe5e3
commit 12d700fd14
3 changed files with 51 additions and 19 deletions

View File

@ -763,8 +763,10 @@ function canInsert(shape, flow, position) {
//
// at this point we are not really able to talk
// about connection rules (yet)
return (
isAny(flow, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ]) &&
!isLabel(flow) &&
is(shape, 'bpmn:FlowNode') &&
!is(shape, 'bpmn:BoundaryEvent') &&
canDrop(shape, flow.parent, position));

View File

@ -1,26 +1,31 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.6.0">
<bpmn:process id="Process" isExecutable="false">
<bpmn:startEvent id="StartEvent">
<bpmn:outgoing>SequenceFlow</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task">
<bpmn:incoming>SequenceFlow</bpmn:incoming>
<bpmn:task id="Task_1">
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow" sourceRef="StartEvent" targetRef="Task" />
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent" targetRef="Task_1" />
<bpmn:intermediateThrowEvent id="IntermediateThrowEvent_foo" />
<bpmn:endEvent id="EndEvent_foo" />
<bpmn:startEvent id="StartEvent_foo" />
<bpmn:task id="Task_2">
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_2" name="FOO BAR" sourceRef="Task_1" targetRef="Task_2" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_di" bpmnElement="Task">
<bpmndi:BPMNShape id="Task_di" bpmnElement="Task_1">
<dc:Bounds x="502" y="259" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_di" bpmnElement="SequenceFlow">
<bpmndi:BPMNEdge id="SequenceFlow_di" bpmnElement="SequenceFlow_1">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="340" y="120" />
<di:waypoint xsi:type="dc:Point" x="340" y="299" />
@ -47,6 +52,16 @@
<dc:Bounds x="552" y="228" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0oupcpb_di" bpmnElement="Task_2">
<dc:Bounds x="797" y="259" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_19qadsw_di" bpmnElement="SequenceFlow_2">
<di:waypoint xsi:type="dc:Point" x="602" y="299" />
<di:waypoint xsi:type="dc:Point" x="797" y="299" />
<bpmndi:BPMNLabel>
<dc:Bounds x="675" y="274" width="50" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -28,7 +28,7 @@ describe('modeling/behavior - drop on connection', function() {
it('should be allowed for an IntermediateThrowEvent', inject(function(elementRegistry, bpmnRules, elementFactory) {
// when
var sequenceFlow = elementRegistry.get('SequenceFlow');
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
// then
@ -48,8 +48,8 @@ describe('modeling/behavior - drop on connection', function() {
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' });
var startEvent = elementRegistry.get('StartEvent'),
sequenceFlow = elementRegistry.get('SequenceFlow'),
task = elementRegistry.get('Task');
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
task = elementRegistry.get('Task_1');
var originalWaypoints = sequenceFlow.waypoints;
@ -96,7 +96,7 @@ describe('modeling/behavior - drop on connection', function() {
// given
var endEventShape = elementFactory.createShape({ type: 'bpmn:EndEvent' });
var sequenceFlow = elementRegistry.get('SequenceFlow');
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var originalWaypoints = sequenceFlow.waypoints;
var dropPosition = { x: 340, y: 120 }; // first bendpoint
@ -126,7 +126,7 @@ describe('modeling/behavior - drop on connection', function() {
// given
var startEventShape = elementFactory.createShape({ type: 'bpmn:StartEvent' });
var sequenceFlow = elementRegistry.get('SequenceFlow');
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var originalWaypoints = sequenceFlow.waypoints;
var dropPosition = { x: 340, y: 120 }; // first bendpoint
@ -164,9 +164,9 @@ describe('modeling/behavior - drop on connection', function() {
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
var startEvent = elementRegistry.get('StartEvent'),
sequenceFlow = elementRegistry.get('SequenceFlow'),
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
task = elementRegistry.get('Task');
task = elementRegistry.get('Task_1');
var originalWaypoints = sequenceFlow.waypoints;
@ -221,7 +221,7 @@ describe('modeling/behavior - drop on connection', function() {
// given
var endEventShape = elementRegistry.get('EndEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow'),
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
@ -260,7 +260,7 @@ describe('modeling/behavior - drop on connection', function() {
var startEventShape = elementRegistry.get('StartEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow'),
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
@ -301,7 +301,7 @@ describe('modeling/behavior - drop on connection', function() {
// given
var startEventShape = elementRegistry.get('StartEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow'),
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
@ -345,7 +345,7 @@ describe('modeling/behavior - drop on connection', function() {
// given
var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' });
var sequenceFlow = elementRegistry.get('SequenceFlow');
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var dropPosition = { x: 340, y: 120 }; // first bendpoint
@ -367,7 +367,7 @@ describe('modeling/behavior - drop on connection', function() {
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'),
endEventShape = elementRegistry.get('EndEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow'),
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow);
var intInitPosition = {
@ -398,6 +398,21 @@ describe('modeling/behavior - drop on connection', function() {
expect(endEventShape).to.have.position(endInitPosition);
}));
it('should not insert on sequence flow label', inject(function(bpmnRules, elementRegistry) {
// given
var eventShape = elementRegistry.get('IntermediateThrowEvent_foo'),
sequenceFlowLabel = elementRegistry.get('SequenceFlow_2').label;
var dropPosition = { x: 675, y: 275 }; // sequence flow label
// when
var canInsert = bpmnRules.canInsert(eventShape, sequenceFlowLabel, dropPosition);
// then
expect(canInsert).to.be.false;
}));
});
});