fix(layout-connection-behavior): do NOT snap on reconnect start and end
Closes #1056
This commit is contained in:
parent
bc5a3f803e
commit
9e5a5f4944
|
@ -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)
|
||||
|
|
|
@ -64,111 +64,38 @@ describe('features/grid-snapping - layout connection', function() {
|
|||
|
||||
describe('on connection layout', function() {
|
||||
|
||||
describe('should snap 3 segment connection (1 middle segment)', function() {
|
||||
var task1, task2, connection;
|
||||
|
||||
var connection;
|
||||
beforeEach(inject(function(elementRegistry, modeling) {
|
||||
|
||||
beforeEach(inject(function(elementRegistry, modeling) {
|
||||
// given
|
||||
task1 = elementRegistry.get('Task_1'),
|
||||
task2 = elementRegistry.get('Task_2');
|
||||
|
||||
// given
|
||||
var task1 = elementRegistry.get('Task_1'),
|
||||
task2 = elementRegistry.get('Task_2');
|
||||
|
||||
connection = modeling.connect(task1, task2);
|
||||
|
||||
// when
|
||||
modeling.moveElements([ task2 ], { x: 50, y: 50 });
|
||||
}));
|
||||
connection = modeling.connect(task1, task2);
|
||||
}));
|
||||
|
||||
|
||||
it('should do', function() {
|
||||
it('should NOT sap on reconnect start', inject(function(modeling) {
|
||||
|
||||
// then
|
||||
expect(connection.waypoints[1]).to.eql({ x: 250, y: 140 });
|
||||
expect(connection.waypoints[2]).to.eql({ x: 250, y: 290 });
|
||||
});
|
||||
// when
|
||||
modeling.moveElements([ task1 ], { x: 50, y: 50 });
|
||||
|
||||
// then
|
||||
expect(connection.waypoints[1]).to.eql({ x: 275, y: 190 });
|
||||
expect(connection.waypoints[2]).to.eql({ x: 275, y: 240 });
|
||||
}));
|
||||
|
||||
|
||||
it('should undo', inject(function(commandStack) {
|
||||
it('should NOT sap on reconnect end', inject(function(modeling) {
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
// when
|
||||
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: 240 });
|
||||
}));
|
||||
|
||||
|
||||
it('should redo', inject(function(commandStack) {
|
||||
|
||||
// given
|
||||
commandStack.undo();
|
||||
|
||||
// when
|
||||
commandStack.redo();
|
||||
|
||||
// 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 });
|
||||
}));
|
||||
|
||||
});
|
||||
// then
|
||||
expect(connection.waypoints[1]).to.eql({ x: 225, y: 140 });
|
||||
expect(connection.waypoints[2]).to.eql({ x: 225, y: 190 });
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue