Merge branch 'master' into develop
This commit is contained in:
commit
14eeba897d
|
@ -68,16 +68,15 @@ BpmnCreateMoveSnapping.prototype.initSnap = function(event) {
|
||||||
|
|
||||||
var shape = event.shape;
|
var shape = event.shape;
|
||||||
|
|
||||||
|
var isMove = !!this._elementRegistry.get(shape.id);
|
||||||
|
|
||||||
// snap to docking points
|
// snap to docking points
|
||||||
forEach(shape.outgoing, function(connection) {
|
forEach(shape.outgoing, function(connection) {
|
||||||
var docking = connection.waypoints[0];
|
var docking = connection.waypoints[0];
|
||||||
|
|
||||||
docking = docking.original || docking;
|
docking = docking.original || docking;
|
||||||
|
|
||||||
snapContext.setSnapOrigin(connection.id + '-docking', {
|
snapContext.setSnapOrigin(connection.id + '-docking', getDockingSnapOrigin(docking, isMove, event));
|
||||||
x: docking.x - event.x,
|
|
||||||
y: docking.y - event.y
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
forEach(shape.incoming, function(connection) {
|
forEach(shape.incoming, function(connection) {
|
||||||
|
@ -85,10 +84,7 @@ BpmnCreateMoveSnapping.prototype.initSnap = function(event) {
|
||||||
|
|
||||||
docking = docking.original || docking;
|
docking = docking.original || docking;
|
||||||
|
|
||||||
snapContext.setSnapOrigin(connection.id + '-docking', {
|
snapContext.setSnapOrigin(connection.id + '-docking', getDockingSnapOrigin(docking, isMove, event));
|
||||||
x: docking.x - event.x,
|
|
||||||
y: docking.y - event.y
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (is(shape, 'bpmn:Participant')) {
|
if (is(shape, 'bpmn:Participant')) {
|
||||||
|
@ -117,20 +113,23 @@ BpmnCreateMoveSnapping.prototype.addSnapTargetPoints = function(snapPoints, shap
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// snap to docking points
|
var elementRegistry = this._elementRegistry;
|
||||||
|
|
||||||
|
// snap to docking points if not create mode
|
||||||
forEach(shape.incoming, function(connection) {
|
forEach(shape.incoming, function(connection) {
|
||||||
|
if (elementRegistry.get(shape.id)) {
|
||||||
|
|
||||||
if (!includes(snapTargets, connection.source)) {
|
if (!includes(snapTargets, connection.source)) {
|
||||||
snapPoints.add('mid', getMid(connection.source));
|
snapPoints.add('mid', getMid(connection.source));
|
||||||
}
|
}
|
||||||
|
|
||||||
var docking = connection.waypoints[0];
|
var docking = connection.waypoints[0];
|
||||||
|
|
||||||
snapPoints.add(connection.id + '-docking', docking.original || docking);
|
snapPoints.add(connection.id + '-docking', docking.original || docking);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
forEach(shape.outgoing, function(connection) {
|
forEach(shape.outgoing, function(connection) {
|
||||||
|
if (elementRegistry.get(shape.id)) {
|
||||||
|
|
||||||
if (!includes(snapTargets, connection.target)) {
|
if (!includes(snapTargets, connection.target)) {
|
||||||
snapPoints.add('mid', getMid(connection.target));
|
snapPoints.add('mid', getMid(connection.target));
|
||||||
|
@ -139,6 +138,7 @@ BpmnCreateMoveSnapping.prototype.addSnapTargetPoints = function(snapPoints, shap
|
||||||
var docking = connection.waypoints[ connection.waypoints.length - 1 ];
|
var docking = connection.waypoints[ connection.waypoints.length - 1 ];
|
||||||
|
|
||||||
snapPoints.add(connection.id + '-docking', docking.original || docking);
|
snapPoints.add(connection.id + '-docking', docking.original || docking);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// add sequence flow parents as snap targets
|
// add sequence flow parents as snap targets
|
||||||
|
@ -229,3 +229,15 @@ function setSnappedIfConstrained(event) {
|
||||||
function includes(array, value) {
|
function includes(array, value) {
|
||||||
return array.indexOf(value) !== -1;
|
return array.indexOf(value) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDockingSnapOrigin(docking, isMove, event) {
|
||||||
|
return isMove ? (
|
||||||
|
{
|
||||||
|
x: docking.x - event.x,
|
||||||
|
y: docking.y - event.y
|
||||||
|
}
|
||||||
|
) : {
|
||||||
|
x: docking.x,
|
||||||
|
y: docking.y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?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_0hu8z4u" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
|
||||||
|
<bpmn:process id="Process_1t22f8o" isExecutable="true">
|
||||||
|
<bpmn:task id="Task_1">
|
||||||
|
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
|
||||||
|
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
|
||||||
|
</bpmn:task>
|
||||||
|
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="Task_1" targetRef="Task_1" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1t22f8o">
|
||||||
|
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
|
||||||
|
<dc:Bounds x="200" y="77" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="SequenceFlow_1_di" bpmnElement="SequenceFlow_1">
|
||||||
|
<di:waypoint x="250" y="157" />
|
||||||
|
<di:waypoint x="250" y="177" />
|
||||||
|
<di:waypoint x="160" y="177" />
|
||||||
|
<di:waypoint x="160" y="117" />
|
||||||
|
<di:waypoint x="200" y="117" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -486,6 +486,8 @@ describe('features/snapping - BpmnCreateMoveSnapping', function() {
|
||||||
|
|
||||||
describe('docking points', function() {
|
describe('docking points', function() {
|
||||||
|
|
||||||
|
describe('move mode', function() {
|
||||||
|
|
||||||
var diagramXML = require('./BpmnCreateMoveSnapping.docking-points.bpmn');
|
var diagramXML = require('./BpmnCreateMoveSnapping.docking-points.bpmn');
|
||||||
|
|
||||||
beforeEach(bootstrapModeler(diagramXML, {
|
beforeEach(bootstrapModeler(diagramXML, {
|
||||||
|
@ -500,7 +502,6 @@ describe('features/snapping - BpmnCreateMoveSnapping', function() {
|
||||||
participantGfx = elementRegistry.getGraphics(participant);
|
participantGfx = elementRegistry.getGraphics(participant);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should snap to docking point (incoming connections)', inject(
|
it('should snap to docking point (incoming connections)', inject(
|
||||||
function(dragging, elementRegistry, move) {
|
function(dragging, elementRegistry, move) {
|
||||||
|
|
||||||
|
@ -551,7 +552,51 @@ describe('features/snapping - BpmnCreateMoveSnapping', function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('create mode', function() {
|
||||||
|
|
||||||
|
var diagramXML = require('./BpmnCreateMoveSnapping.docking-create-mode.bpmn');
|
||||||
|
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(diagramXML, {
|
||||||
|
modules: testModules
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should correctly set snap origins', function(done) {
|
||||||
|
|
||||||
|
var test = inject(function(elementRegistry, copyPaste, eventBus) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var task1 = elementRegistry.get('Task_1');
|
||||||
|
eventBus.on('create.start', function(event) {
|
||||||
|
|
||||||
|
var snapContext = event.context.snapContext;
|
||||||
|
var snapLocations = snapContext.getSnapLocations();
|
||||||
|
var sequenceFlowSnapOrigin = snapContext.getSnapOrigin(snapLocations[3]);
|
||||||
|
|
||||||
|
// then
|
||||||
|
try {
|
||||||
|
expect(sequenceFlowSnapOrigin.x).to.be.eql(-30);
|
||||||
|
expect(sequenceFlowSnapOrigin.y).to.be.eql(-10);
|
||||||
|
|
||||||
|
done();
|
||||||
|
} catch (error) {
|
||||||
|
done(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// when
|
||||||
|
copyPaste.copy(task1);
|
||||||
|
copyPaste.paste();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue