module Adminterface::Extensions::BatchActions::BatchActionSelector

Public Instance Methods

dropdown_menu(name, options = {}) click to toggle source
Calls superclass method

Private Instance Methods

build_drop_down() click to toggle source
# File lib/adminterface/extensions/batch_actions/views/batch_action_selector.rb, line 13
def build_drop_down
  return if batch_actions_to_display.empty?

  dropdown_menu I18n.t("active_admin.batch_actions.button_label"),
    class: "batch_actions_selector dropdown_menu",
    button: {class: "disabled"} do
    batch_actions_to_display.each do |batch_action|
      confirmation_text = render_or_call_method_or_proc_on(self, batch_action.confirm)

      options = {
        id: "batch-action-#{batch_action.sym}",
        class: "batch_action",
        "data-action": batch_action.sym,
        "data-confirm": confirmation_text,
        "data-inputs": render_in_context(self, batch_action.inputs).to_json,
        "data-aa-confirm-dialog": render_in_context(self, batch_action.confirm_dialog).to_json
      }

      default_title = render_or_call_method_or_proc_on(self, batch_action.title)
      title = I18n.t("active_admin.batch_actions.labels.#{batch_action.sym}", default: default_title)
      label = I18n.t("active_admin.batch_actions.action_label", title: title)

      item label, "#", **options
    end
  end
end