fix(associations): always show full data association

Closes #506
This commit is contained in:
Vladimirs Katusenoks 2016-05-09 12:38:01 +02:00 committed by Ricardo Matias
parent 5a02923a61
commit 006be69d63
6 changed files with 127 additions and 14 deletions

View File

@ -407,7 +407,7 @@ BpmnUpdater.prototype.getLaneSet = function(container) {
return laneSet;
};
BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) {
BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent, visualParent) {
var containment,
translate = this._translate;
@ -527,6 +527,22 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent)
children.push(businessObject);
businessObject.$parent = newParent;
}
if (visualParent) {
var diChildren = visualParent.get(containment);
Collections.remove(children, businessObject);
if (newParent) {
if (!diChildren) {
diChildren = [];
newParent.set(containment, diChildren);
}
diChildren.push(businessObject);
}
}
};
@ -540,7 +556,8 @@ BpmnUpdater.prototype.updateConnection = function(context) {
var connection = context.connection,
businessObject = getBusinessObject(connection),
newSource = getBusinessObject(connection.source),
newTarget = getBusinessObject(connection.target);
newTarget = getBusinessObject(connection.target),
visualParent;
if (!is(businessObject, 'bpmn:DataAssociation')) {
@ -575,13 +592,15 @@ BpmnUpdater.prototype.updateConnection = function(context) {
// handle obnoxious isMany sourceRef
businessObject.get('sourceRef')[0] = newSource;
// targetRef = new parent
this.updateSemanticParent(businessObject, newTarget);
visualParent = context.parent || context.newParent || newTarget;
this.updateSemanticParent(businessObject, newTarget, parent.businessObject);
} else
if (is(businessObject, 'bpmn:DataOutputAssociation')) {
// sourceRef = new parent
this.updateSemanticParent(businessObject, newSource);
visualParent = context.parent || context.newParent || newSource;
this.updateSemanticParent(businessObject, newSource, visualParent);
// targetRef = new target
businessObject.targetRef = newTarget;

View File

@ -34,6 +34,9 @@ function BpmnOrderingProvider(eventBus, translate) {
]
}
},
{ type: 'bpmn:DataInputAssociation', order: { level: 9, containers: [ 'bpmn:Collaboration', 'bpmn:Process' ] } },
{ type: 'bpmn:DataOutputAssociation', order: { level: 9, containers: [ 'bpmn:Collaboration', 'bpmn:Process' ] } },
{ type: 'bpmn:MessageFlow', order: { level: 9, containers: [ 'bpmn:Collaboration' ] } },
{
type: 'bpmn:Association',
order: {
@ -45,7 +48,6 @@ function BpmnOrderingProvider(eventBus, translate) {
]
}
},
{ type: 'bpmn:MessageFlow', order: { level: 9, containers: [ 'bpmn:Collaboration' ] } },
{ type: 'bpmn:BoundaryEvent', order: { level: 8 } },
{ type: 'bpmn:Participant', order: { level: -2 } },
{ type: 'bpmn:Lane', order: { level: -1 } }

View File

@ -114,6 +114,11 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
waypoints: collectWaypoints(semantic.di.waypoint)
}));
if (is(semantic, 'bpmn:DataInputAssociation') || is(semantic, 'bpmn:DataOutputAssociation')) {
// implicit root element
parentElement = null;
}
this._canvas.addConnection(element, parentElement);
} else {
throw new Error(translate('unknown di {di} for element {semantic}', {

View File

@ -1,6 +1,6 @@
'use strict';
var TestHelper = require('../../../../TestHelper');
require('../../../../TestHelper');
/* global bootstrapModeler, inject */

View File

@ -85,6 +85,50 @@ describe('features/modeling - ordering', function() {
expectZOrder('Participant_StartEvent', 'Participant', 'MessageFlow');
}));
it('should stay behind DataInputAssociation when moving Participant with DataStore', inject(function() {
// when
move('Participant', { x: 5, y: 5 });
// then
expectZOrder('Participant', 'DataInputAssociation');
expectZOrder('Participant_StartEvent', 'DataInputAssociation');
}));
it('should stay behind DataInputAssociation when moving Participant with Task', inject(function() {
// when
move('Participant_StartEvent', { x: 5, y: 5 });
// then
expectZOrder('Participant', 'DataInputAssociation');
expectZOrder('Participant_StartEvent', 'DataInputAssociation');
}));
it('should stay behind DataOutputAssociation when moving Participant with DataStore', inject(function() {
// when
move('Participant', { x: 5, y: 5 });
// then
expectZOrder('Participant', 'DataOutputAssociation');
expectZOrder('Participant_StartEvent', 'DataOutputAssociation');
}));
it('should stay behind DataOutputAssociation when moving Participant with Task', inject(function() {
// when
move('Participant_StartEvent', { x: 5, y: 5 });
// then
expectZOrder('Participant', 'DataOutputAssociation');
expectZOrder('Participant_StartEvent', 'DataOutputAssociation');
}));
});

View File

@ -1,36 +1,53 @@
<?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: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="_Sp0bEEZWEeW8AbPIK3dKxg" targetNamespace="http://activiti.org/bpmn" exporter="camunda modeler" exporterVersion="2.6.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: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="_Sp0bEEZWEeW8AbPIK3dKxg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="0.7.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="Collaboration">
<bpmn2:participant id="Participant" name="Participant" processRef="Process_Tasks" />
<bpmn2:participant id="Participant_StartEvent" name="Participant_StartEvent" processRef="Process_StartEvent" />
<bpmn2:messageFlow id="MessageFlow" name="" sourceRef="Task_With_Boundary" targetRef="Participant_StartEvent" />
</bpmn2:collaboration>
<bpmn2:process id="Process_Tasks" isExecutable="false">
<bpmn2:task id="Task_With_Boundary" />
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="BoundaryEvent" targetRef="Task" />
<bpmn2:boundaryEvent id="BoundaryEvent" name="" attachedToRef="Task_With_Boundary">
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
</bpmn2:boundaryEvent>
<bpmn2:task id="Task_With_Boundary" />
<bpmn2:task id="Task">
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="BoundaryEvent" targetRef="Task" />
<bpmn2:dataStoreReference id="DataStore" />
<bpmn2:dataStoreReference id="DataStore_With_Output" />
</bpmn2:process>
<bpmn2:process id="Process_StartEvent" isExecutable="false">
<bpmn2:task id="Task_With_Input">
<bpmn2:property id="Property_17cs768" name="__targetRef_placeholder" />
<bpmn2:dataInputAssociation id="DataInputAssociation">
<bpmn2:sourceRef>DataStore</bpmn2:sourceRef>
<bpmn2:targetRef>Property_17cs768</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
</bpmn2:task>
<bpmn2:startEvent id="StartEvent" name="StartEvent" />
<bpmn2:task id="Task_With_Output">
<bpmn2:dataOutputAssociation id="DataOutputAssociation">
<bpmn2:targetRef>DataStore_With_Output</bpmn2:targetRef>
</bpmn2:dataOutputAssociation>
</bpmn2:task>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant" isHorizontal="true">
<dc:Bounds x="192" y="108" width="457" height="193" />
<dc:Bounds x="192" y="108" width="686" height="198" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_StartEvent" isHorizontal="true">
<dc:Bounds x="192" y="444" width="457" height="158" />
<dc:Bounds x="192" y="444" width="685" height="160" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_With_Boundary">
<dc:Bounds x="300" y="144" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_2" bpmnElement="BoundaryEvent">
<dc:Bounds x="346" y="206" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="319" y="242" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
<dc:Bounds x="480" y="144" width="100" height="80" />
@ -41,7 +58,7 @@
<di:waypoint xsi:type="dc:Point" x="530" y="272" />
<di:waypoint xsi:type="dc:Point" x="530" y="224" />
<bpmndi:BPMNLabel>
<dc:Bounds x="471" y="272" width="6" height="6" />
<dc:Bounds x="429" y="272" width="90" height="6" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_1" bpmnElement="MessageFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Participant_3">
@ -57,6 +74,32 @@
<dc:Bounds x="244" y="531" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataStoreReference_0g20j8u_di" bpmnElement="DataStore">
<dc:Bounds x="629" y="159" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="609" y="209" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1w5ze4k_di" bpmnElement="Task_With_Input">
<dc:Bounds x="604" y="473" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataInputAssociation_1ubbgym_di" bpmnElement="DataInputAssociation">
<di:waypoint xsi:type="dc:Point" x="654" y="209" />
<di:waypoint xsi:type="dc:Point" x="654" y="473" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="DataStoreReference_0jbctd4_di" bpmnElement="DataStore_With_Output">
<dc:Bounds x="772" y="159" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="752" y="209" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0vcqjeq_di" bpmnElement="Task_With_Output">
<dc:Bounds x="747" y="473" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataOutputAssociation_1fcd0id_di" bpmnElement="DataOutputAssociation">
<di:waypoint xsi:type="dc:Point" x="797" y="473" />
<di:waypoint xsi:type="dc:Point" x="797" y="209" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>