/** 重启流程按钮 */


var angular = require('angular');
require('../modules');
require('../../linker/services/UserChooser');

var module = angular.module('flowmodulebutton.directives');

/**
  <sino-flow-reuse-button
     flow-type=""
     record-id=""
     show="" 展示权限 默认false
     name="" 名称
   ></sino-flow-reuse-button>
 */
module.directive('sinoFlowDispenseButton', function($toast, $ionicModal,
  linkerConfig, UserChooser) {

  return {
    restrict: 'E',
    require: '^sinoFlowButtonBar',
    scope: {
      show: '=show',
      closeFn: '&'
    },
    link: function(scope, element, attrs, ctrl) {

      ctrl.button(function() {
        return {
          id: 'dispense',
          name: attrs.name,
          show: scope.show,
          onClick: openSelectUserModal
        }
      });

      function openSelectUserModal() {
        UserChooser.choose(scope, element, attrs);
      }

    }
  }
});
