all files / lib/features/modeling/cmd/ LayoutConnectionHandler.js

100% Statements 13/13
100% Branches 0/0
100% Functions 3/3
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37              559× 559×         68×   68×   68×       68×   68×       15×   15×   15×    
import { assign } from 'min-dash';
 
 
/**
 * A handler that implements reversible moving of shapes.
 */
export default function LayoutConnectionHandler(layouter, canvas) {
  this._layouter = layouter;
  this._canvas = canvas;
}
 
LayoutConnectionHandler.$inject = [ 'layouter', 'canvas' ];
 
LayoutConnectionHandler.prototype.execute = function(context) {
 
  var connection = context.connection;
 
  var oldWaypoints = connection.waypoints;
 
  assign(context, {
    oldWaypoints: oldWaypoints
  });
 
  connection.waypoints = this._layouter.layoutConnection(connection, context.hints);
 
  return connection;
};
 
LayoutConnectionHandler.prototype.revert = function(context) {
 
  var connection = context.connection;
 
  connection.waypoints = context.oldWaypoints;
 
  return connection;
};