fix(layout-connection-behavior): do NOT snap on reconnect start and end

Closes #1056
This commit is contained in:
Philipp Fromme 2019-05-29 11:37:31 +02:00 committed by merge-me[bot]
parent bc5a3f803e
commit 9e5a5f4944
2 changed files with 27 additions and 95 deletions

View File

@ -23,8 +23,13 @@ export default function LayoutConnectionBehavior(eventBus, gridSnapping, modelin
], HIGH_PRIORITY, function(event) {
var context = event.context,
connection = context.connection,
hints = context.hints || {},
waypoints = connection.waypoints;
if (hints.connectionStart || hints.connectionEnd) {
return;
}
if (hasMiddleSegments(waypoints)) {
modeling.updateProperties(connection, {
waypoints: self.snapMiddleSegments(waypoints)

View File

@ -64,112 +64,39 @@ describe('features/grid-snapping - layout connection', function() {
describe('on connection layout', function() {
describe('should snap 3 segment connection (1 middle segment)', function() {
var connection;
var task1, task2, connection;
beforeEach(inject(function(elementRegistry, modeling) {
// given
var task1 = elementRegistry.get('Task_1'),
task1 = elementRegistry.get('Task_1'),
task2 = elementRegistry.get('Task_2');
connection = modeling.connect(task1, task2);
// when
modeling.moveElements([ task2 ], { x: 50, y: 50 });
}));
it('should do', function() {
// then
expect(connection.waypoints[1]).to.eql({ x: 250, y: 140 });
expect(connection.waypoints[2]).to.eql({ x: 250, y: 290 });
});
it('should undo', inject(function(commandStack) {
it('should NOT sap on reconnect start', inject(function(modeling) {
// when
commandStack.undo();
modeling.moveElements([ task1 ], { x: 50, y: 50 });
// then
expect(connection.waypoints[1]).to.eql({ x: 250, y: 140 });
expect(connection.waypoints[2]).to.eql({ x: 250, y: 240 });
expect(connection.waypoints[1]).to.eql({ x: 275, y: 190 });
expect(connection.waypoints[2]).to.eql({ x: 275, y: 240 });
}));
it('should redo', inject(function(commandStack) {
// given
commandStack.undo();
it('should NOT sap on reconnect end', inject(function(modeling) {
// when
commandStack.redo();
modeling.moveElements([ task2 ], { x: -50, y: -50 });
// then
expect(connection.waypoints[1]).to.eql({ x: 250, y: 140 });
expect(connection.waypoints[2]).to.eql({ x: 250, y: 290 });
}));
});
describe('should snap 4 segment connection (2 middle segments)', function() {
var connection;
beforeEach(inject(function(elementRegistry, modeling) {
// given
var boundaryEvent1 = elementRegistry.get('BoundaryEvent_1'),
task4 = elementRegistry.get('Task_4');
connection = modeling.connect(boundaryEvent1, task4);
// when
modeling.moveElements([ task4 ], { x: 50, y: 50 });
}));
it('should do', function() {
// then
expect(connection.waypoints[1]).to.eql({ x: 150, y: 520 });
expect(connection.waypoints[2]).to.eql({ x: 230, y: 520 });
expect(connection.waypoints[3]).to.eql({ x: 230, y: 490 });
});
it('should undo', inject(function(commandStack) {
// when
commandStack.undo();
// then
expect(connection.waypoints[1]).to.eql({ x: 150, y: 520 });
expect(connection.waypoints[2]).to.eql({ x: 230, y: 520 });
expect(connection.waypoints[3]).to.eql({ x: 230, y: 440 });
}));
it('should redo', inject(function(commandStack) {
// given
commandStack.undo();
// when
commandStack.redo();
// then
expect(connection.waypoints[1]).to.eql({ x: 150, y: 520 });
expect(connection.waypoints[2]).to.eql({ x: 230, y: 520 });
expect(connection.waypoints[3]).to.eql({ x: 230, y: 490 });
expect(connection.waypoints[1]).to.eql({ x: 225, y: 140 });
expect(connection.waypoints[2]).to.eql({ x: 225, y: 190 });
}));
});
});
});