fix(rules): allow labels to be dropped everywhere

Closes #849
This commit is contained in:
Nico Rehwaldt 2018-08-22 10:56:57 +02:00 committed by Nico Rehwaldt
parent 8a6ab27b04
commit 905ee6f667
3 changed files with 78 additions and 7 deletions

View File

@ -420,7 +420,7 @@ function canConnect(source, target, connection) {
function canDrop(element, target, position) { function canDrop(element, target, position) {
// can move labels everywhere // can move labels everywhere
if (isLabel(element) && !isConnection(target)) { if (isLabel(element)) {
return true; return true;
} }

View File

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?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" 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: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:collaboration id="Collaboration">
<bpmn2:participant id="Participant" name="Pool" processRef="Process" /> <bpmn2:participant id="Participant" name="Pool" processRef="Process" />
<bpmn2:participant id="OtherParticipant" name="Pool" processRef="OtherProcess" /> <bpmn2:participant id="OtherParticipant" name="Pool" processRef="OtherProcess" />
<bpmn2:participant id="CollapsedParticipant" name="Pool" /> <bpmn2:participant id="CollapsedParticipant" name="Pool" />
<bpmn2:messageFlow id="MessageFlow_labeled" name="LABEL" sourceRef="Participant" targetRef="OtherParticipant" />
<bpmn2:messageFlow id="MessageFlow_2" sourceRef="OtherParticipant" targetRef="SubProcess" />
<bpmn2:textAnnotation id="TextAnnotation_Global" /> <bpmn2:textAnnotation id="TextAnnotation_Global" />
</bpmn2:collaboration> </bpmn2:collaboration>
<bpmn2:process id="Process" isExecutable="false"> <bpmn2:process id="Process" isExecutable="false">
@ -21,23 +23,32 @@
<bpmn2:endEvent id="EndEvent_Message"> <bpmn2:endEvent id="EndEvent_Message">
<bpmn2:messageEventDefinition /> <bpmn2:messageEventDefinition />
</bpmn2:endEvent> </bpmn2:endEvent>
<bpmn2:endEvent id="EndEvent_None" /> <bpmn2:endEvent id="EndEvent_None">
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_Escalation"> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_Escalation">
<bpmn2:escalationEventDefinition /> <bpmn2:escalationEventDefinition />
</bpmn2:intermediateCatchEvent> </bpmn2:intermediateCatchEvent>
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_Message"> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_Message">
<bpmn2:messageEventDefinition id="MessageEventDefinition_1" /> <bpmn2:messageEventDefinition id="MessageEventDefinition_1" />
</bpmn2:intermediateThrowEvent> </bpmn2:intermediateThrowEvent>
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_None" /> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_None">
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
</bpmn2:intermediateThrowEvent>
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_Signal"> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_Signal">
<bpmn2:signalEventDefinition /> <bpmn2:signalEventDefinition />
</bpmn2:intermediateThrowEvent> </bpmn2:intermediateThrowEvent>
<bpmn2:endEvent id="EndEvent_Cancel"> <bpmn2:endEvent id="EndEvent_Cancel">
<bpmn2:cancelEventDefinition /> <bpmn2:cancelEventDefinition />
</bpmn2:endEvent> </bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow" sourceRef="IntermediateThrowEvent_None" targetRef="EndEvent_None" />
</bpmn2:process> </bpmn2:process>
<bpmn2:process id="OtherProcess" isExecutable="false"> <bpmn2:process id="OtherProcess" isExecutable="false">
<bpmn2:task id="Task_in_OtherParticipant" /> <bpmn2:task id="Task_in_OtherParticipant">
<bpmn2:dataOutputAssociation id="DataOutputAssociation">
<bpmn2:targetRef>DataStoreReference</bpmn2:targetRef>
</bpmn2:dataOutputAssociation>
</bpmn2:task>
<bpmn2:dataStoreReference id="DataStoreReference" /> <bpmn2:dataStoreReference id="DataStoreReference" />
<bpmn2:textAnnotation id="TextAnnotation_OtherParticipant" /> <bpmn2:textAnnotation id="TextAnnotation_OtherParticipant" />
</bpmn2:process> </bpmn2:process>
@ -140,6 +151,25 @@
<dc:Bounds x="696.8233151183972" y="534" width="0" height="12" /> <dc:Bounds x="696.8233151183972" y="534" width="0" height="12" />
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="MessageFlow_labeled_di" bpmnElement="MessageFlow_labeled">
<di:waypoint x="425" y="314" />
<di:waypoint x="425" y="432" />
<bpmndi:BPMNLabel>
<dc:Bounds x="433" y="364" width="35" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_2_di" bpmnElement="MessageFlow_2">
<di:waypoint x="551" y="432" />
<di:waypoint x="551" y="277" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="DataOutputAssociation_di" bpmnElement="DataOutputAssociation">
<di:waypoint x="508" y="505" />
<di:waypoint x="672" y="505" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_di" bpmnElement="SequenceFlow">
<di:waypoint x="275" y="252" />
<di:waypoint x="417" y="252" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane> </bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram> </bpmndi:BPMNDiagram>
</bpmn2:definitions> </bpmn2:definitions>

View File

@ -924,7 +924,6 @@ describe('features/modeling/rules - BpmnRules', function() {
it('drop TextAnnotation_Global -> Participant', inject(function() { it('drop TextAnnotation_Global -> Participant', inject(function() {
expectCanDrop('TextAnnotation_Global', 'Participant', true); expectCanDrop('TextAnnotation_Global', 'Participant', true);
})); }));
@ -934,13 +933,55 @@ describe('features/modeling/rules - BpmnRules', function() {
}); });
it('drop element -> collapsed Participant', inject(function(canvas) { it('drop element -> collapsed Participant', inject(function() {
expectCanDrop('StartEvent_None', 'CollapsedParticipant', false); expectCanDrop('StartEvent_None', 'CollapsedParticipant', false);
expectCanDrop('SubProcess', 'CollapsedParticipant', false); expectCanDrop('SubProcess', 'CollapsedParticipant', false);
expectCanDrop('Task_in_SubProcess', 'CollapsedParticipant', false); expectCanDrop('Task_in_SubProcess', 'CollapsedParticipant', false);
expectCanDrop('TextAnnotation_Global', 'CollapsedParticipant', false); expectCanDrop('TextAnnotation_Global', 'CollapsedParticipant', false);
})); }));
describe('drop MessageFlow label', function() {
var label;
beforeEach(inject(function(elementRegistry) {
label = elementRegistry.get('MessageFlow_labeled').label;
}));
it('-> MessageFlow', function() {
expectCanDrop(label, 'MessageFlow_labeled', true);
});
it('-> CollapsedParticipant', function() {
expectCanDrop(label, 'CollapsedParticipant', true);
});
it('-> Collaboration', function() {
// then
expectCanDrop(label, 'Collaboration', true);
});
it('-> Task_in_SubProcess', function() {
expectCanDrop(label, 'Task_in_SubProcess', true);
});
it('-> SequenceFlow', function() {
expectCanDrop(label, 'SequenceFlow', true);
});
it('-> DataOutputAssociation', function() {
expectCanDrop(label, 'DataOutputAssociation', true);
});
});
}); });