'use strict';

app.directive('addDelayStep', function ($modal, $timeout) {
  return {
    restrict: 'A',
    scope: {
      steps: '='
    },
    link: function(scope, element, attrs) {
      var modal = $modal({scope: scope, title: 'Set delay time', template: 'views/modal-tpls/add-delay.html', show: false});
      

      scope.addDelay = function (time) {
        scope.steps = scope.steps || [];
        scope.steps.push({name: 'Delay ' + time + ' seconds', type: 2, value: time*1000});
        // $timeout(function(){
        //   delete scope.delay;
        // }, 500);
      }; 

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

    }
  };
});