'use strict';

app.directive('addJumpTo', function ($modal, $timeout) {
  return {
    restrict: 'A',
    scope: {
      steps: '=',
      devices: '='
    },
    controller: function($scope, $element) {
      var modal = $modal({scope: $scope, title: 'Add a jump to a device', template: 'views/modal-tpls/add-jump-to.html', show: false});
      
      $scope.addJumpTo = function (device) {
        $scope.steps = $scope.steps || [];
        $scope.steps.push({'name': 'Jump to ' + device.name, 'type': 3, 'to': {'type': 1, 'value': device.id} });
      }; 

      $element.on('click', function(event) {
        event.preventDefault();
        $scope.jump = {};
        modal.$promise.then(modal.show);
      });
    }
  };
});