module ActiveAdmin::BatchActions::ResourceExtension
def add_batch_action(sym, title, options = {}, &block)
-
options
(Hash
) -- -
title
(String
) --
def add_batch_action(sym, title, options = {}, &block) @batch_actions[sym] = ActiveAdmin::BatchAction.new(sym, title, options, &block) end
def add_default_batch_actions
-
(ActiveAdmin::BatchAction)
- The default "delete" action
def add_default_batch_actions destroy_options = { :priority => 100, :confirm => proc { I18n.t('active_admin.batch_actions.delete_confirmation', :plural_model => active_admin_config.plural_resource_label.downcase) }, :if => proc{ controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, active_admin_config.resource_class) } } add_batch_action :destroy, proc { I18n.t('active_admin.delete') }, destroy_options do |selected_ids| active_admin_config.resource_class.find(selected_ids).each { |r| r.destroy } redirect_to active_admin_config.route_collection_path(params), :notice => I18n.t("active_admin.batch_actions.succesfully_destroyed", :count => selected_ids.count, :model => active_admin_config.resource_label.downcase, :plural_model => active_admin_config.plural_resource_label(:count => selected_ids.count).downcase) end end
def batch_action_path(params = {})
def batch_action_path(params = {}) [route_collection_path(params), "batch_action"].join("/") end
def batch_actions
-
(Array)
- The set of batch actions for this resource
def batch_actions batch_actions_enabled? ? @batch_actions.values.sort : [] end
def batch_actions=(bool)
Disable or Enable batch actions for this resource
def batch_actions=(bool) @batch_actions_enabled = bool end
def batch_actions_enabled?
-
(Boolean)
- If batch actions are enabled for this resource
def batch_actions_enabled? # If the resource config has been set, use it. Otherwise # return the namespace setting @batch_actions_enabled.nil? ? namespace.batch_actions : @batch_actions_enabled end
def clear_batch_actions!
def clear_batch_actions! @batch_actions = {} end
def initialize(*)
def initialize(*) super @batch_actions = {} add_default_batch_actions end
def remove_batch_action(sym)
-
sym
(Symbol
) --
def remove_batch_action(sym) @batch_actions.delete(sym.to_sym) end