#encoding
module RailsAdmin
  module Config
    module Actions
      class CheckWxkuCommodity < RailsAdmin::Config::Actions::Base
        register_instance_option :visible?  do
          if not bindings[:object].blank?
               if  bindings[:object].class.base_class.name == 'WxkuCommodity'
                authorized? && bindings[:object].status_ticket != ''
               else
                authorized?
              end             
          else
            authorized?
          end
        end

        register_instance_option :member do
            true
        end

        register_instance_option :link_icon do
            'icon-refresh'
        end

        register_instance_option :pjax? do
            false
        end

        register_instance_option :controller do
          Proc.new do
            redirect_to "#{CONFIG_FILE["api_host"]}/railsadmin/wxku_commodity/#{@object.id}/check"
          end
        end
      end
    end
  end
end