Merge branch 'master' into develop

This commit is contained in:
Nico Rehwaldt 2019-10-31 14:37:26 +01:00
commit dfffe9177e
6 changed files with 104 additions and 7 deletions

View File

@ -6,6 +6,10 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen
___Note:__ Yet to be released changes appear here._ ___Note:__ Yet to be released changes appear here._
## 5.1.2
* `FIX`: account for label pasting in label behavior ([#1227](https://github.com/bpmn-io/bpmn-js/issues/1227))
## 5.1.1 ## 5.1.1
* `FIX`: re-select only existing elements when dragging is finished ([#1225](https://github.com/bpmn-io/bpmn-js/issues/1225)) * `FIX`: re-select only existing elements when dragging is finished ([#1225](https://github.com/bpmn-io/bpmn-js/issues/1225))

View File

@ -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;
} }

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "bpmn-js", "name": "bpmn-js",
"version": "5.1.1", "version": "5.1.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "bpmn-js", "name": "bpmn-js",
"version": "5.1.1", "version": "5.1.2",
"description": "A bpmn 2.0 toolkit and web modeler", "description": "A bpmn 2.0 toolkit and web modeler",
"scripts": { "scripts": {
"all": "run-s lint test distro test:distro", "all": "run-s lint test distro test:distro",

View File

@ -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>

View File

@ -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) {