/** 基础功能按钮 */


var angular = require('angular');
require('../modules');

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

/**
  <sino-flow-base-button
    name="" 显示名称
    class-name="" 按钮图片
    order="" 排序
    on-click="onCllick()" 点击方法
    show="" 展示权限 默认false
    confirm="" 展示确认按钮权限
  ></sino-flow-base-button>
 */
module.directive('sinoFlowBaseButton', function() {
  return {
    restrict: 'E',
    require: '^sinoFlowButtonBar',
    link: function(scope, element, attrs, ctrl) {
      ctrl.button(function() {
        return {
          id: attrs.buttonId,
          title: attrs.text,
          sql: attrs.sql,
          name: attrs.name,
          className: attrs.className,
          order: scope.$eval(attrs.order),
          onClick: function() {
            scope.$eval(attrs.onClick);
          },
          show: attrs.show ? scope.$eval(attrs.show) : true,
          confirm: scope.$eval(attrs.confirm)
        };
      });
    }
  };
});
