fix(modeling): skip moving if label is not yet created.
Related to https://github.com/zeebe-io/zeebe-modeler/issues/134
This commit is contained in:
parent
c74b329a82
commit
64d360575b
|
@ -212,7 +212,12 @@ export default function LabelBehavior(
|
||||||
var label = event.context.connection.label,
|
var label = event.context.connection.label,
|
||||||
labelAdjustment;
|
labelAdjustment;
|
||||||
|
|
||||||
if (!label) {
|
// handle missing label as well as the case
|
||||||
|
// that the label parent does not exist (yet),
|
||||||
|
// because it is being pasted / created via multi element create
|
||||||
|
//
|
||||||
|
// Cf. https://github.com/bpmn-io/bpmn-js/pull/1227
|
||||||
|
if (!label || !label.parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,4 +391,4 @@ function getNearestLine(point, lines) {
|
||||||
var sorted = sortBy(distances, 'distance');
|
var sorted = sortBy(distances, 'distance');
|
||||||
|
|
||||||
return sorted[0].line;
|
return sorted[0].line;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0cu5n0d" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.0">
|
||||||
|
<bpmn:process id="Process_1cirp64" isExecutable="true">
|
||||||
|
<bpmn:startEvent id="Source">
|
||||||
|
<bpmn:outgoing>SequenceFlow</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:task id="Target">
|
||||||
|
<bpmn:incoming>SequenceFlow</bpmn:incoming>
|
||||||
|
</bpmn:task>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow" name="A" sourceRef="Source" targetRef="Target" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1cirp64">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Source">
|
||||||
|
<dc:Bounds x="179" y="79" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_1m56bsl_di" bpmnElement="Target">
|
||||||
|
<dc:Bounds x="300" y="250" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_di" bpmnElement="SequenceFlow">
|
||||||
|
<di:waypoint x="215" y="97" />
|
||||||
|
<di:waypoint x="258" y="97" />
|
||||||
|
<di:waypoint x="258" y="290" />
|
||||||
|
<di:waypoint x="300" y="290" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="270" y="191" width="7" height="14" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -15,15 +15,19 @@ import {
|
||||||
|
|
||||||
import modelingModule from 'lib/features/modeling';
|
import modelingModule from 'lib/features/modeling';
|
||||||
import coreModule from 'lib/core';
|
import coreModule from 'lib/core';
|
||||||
|
import gridSnappingModule from 'lib/features/grid-snapping';
|
||||||
|
|
||||||
|
|
||||||
describe('behavior - LabelBehavior', function() {
|
describe('behavior - LabelBehavior', function() {
|
||||||
|
|
||||||
var diagramXML = require('./LabelBehavior.bpmn');
|
var diagramXML = require('./LabelBehavior.bpmn');
|
||||||
|
|
||||||
var testModules = [ modelingModule, coreModule ];
|
beforeEach(bootstrapModeler(diagramXML, {
|
||||||
|
modules: [
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
modelingModule,
|
||||||
|
coreModule
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
describe('updating name property', function() {
|
describe('updating name property', function() {
|
||||||
|
@ -669,6 +673,59 @@ describe('behavior - LabelBehavior', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('behavior - LabelBehavior', function() {
|
||||||
|
|
||||||
|
describe('copy/paste integration', function() {
|
||||||
|
|
||||||
|
var diagramXML = require('./LabelBehavior.copyPaste.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(diagramXML, {
|
||||||
|
modules: [
|
||||||
|
modelingModule,
|
||||||
|
coreModule,
|
||||||
|
gridSnappingModule
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should skip adjustment during creation', inject(
|
||||||
|
function(elementRegistry, copyPaste, canvas, dragging) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var elements = [
|
||||||
|
elementRegistry.get('Source'),
|
||||||
|
elementRegistry.get('Target'),
|
||||||
|
elementRegistry.get('SequenceFlow'),
|
||||||
|
elementRegistry.get('SequenceFlow').label
|
||||||
|
];
|
||||||
|
|
||||||
|
var rootElement = canvas.getRootElement();
|
||||||
|
|
||||||
|
copyPaste.copy(elements);
|
||||||
|
|
||||||
|
// when
|
||||||
|
var pastedElements = copyPaste.paste({
|
||||||
|
element: rootElement,
|
||||||
|
point: {
|
||||||
|
x: 700,
|
||||||
|
y: 300
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var label = pastedElements[3];
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(label).to.exist;
|
||||||
|
|
||||||
|
expect(label).to.have.position({ x: 681, y: 287 });
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// helpers //////////
|
// helpers //////////
|
||||||
|
|
||||||
function getBounds(element) {
|
function getBounds(element) {
|
||||||
|
|
Loading…
Reference in New Issue