Module: ActiveAdmin::Resource::ActionItems

Included in:
Page, ActiveAdmin::Resource
Defined in:
lib/active_admin/resource/action_items.rb

Instance Method Summary (collapse)

Instance Method Details

- (Array) action_items

Returns The set of action items for this resource

Returns:

  • (Array)

    The set of action items for this resource



15
16
17
# File 'lib/active_admin/resource/action_items.rb', line 15

def action_items
  @action_items ||= []
end

- (Boolean) action_items?

Used by active_admin Base view

Returns:

  • (Boolean)


45
46
47
# File 'lib/active_admin/resource/action_items.rb', line 45

def action_items?
  !!@action_items && @action_items.any?
end

- (Array) action_items_for(action, render_context = nil)

Returns a set of action items to display for a specific controller action

Parameters:

  • action (String, Symbol)

    the action to retrieve action items for

Returns:

  • (Array)

    Array of ActionItems for the controller actions



35
36
37
# File 'lib/active_admin/resource/action_items.rb', line 35

def action_items_for(action, render_context = nil)
  action_items.select{ |item| item.display_on? action, render_context }
end

- (Object) add_action_item(options = {}, &block)

Add a new action item to a resource

Parameters:

  • options (Hash) (defaults to: {})

    valid keys include: :only: A single or array of controller actions to display

    this action item on.

    :except: A single or array of controller actions not to

    display this action item on.


26
27
28
# File 'lib/active_admin/resource/action_items.rb', line 26

def add_action_item(options = {}, &block)
  self.action_items << ActiveAdmin::ActionItem.new(options, &block)
end

- (Object) clear_action_items!

Clears all the existing action items for this resource



40
41
42
# File 'lib/active_admin/resource/action_items.rb', line 40

def clear_action_items!
  @action_items = []
end

- (Object) initialize(*args)

Adds the default action items to a resource when it's initialized



9
10
11
12
# File 'lib/active_admin/resource/action_items.rb', line 9

def initialize(*args)
  super
  add_default_action_items
end