Module: ActiveAdmin::Resource::ActionItems
- Included in:
- Page, ActiveAdmin::Resource
- Defined in:
- lib/active_admin/resource/action_items.rb
Instance Method Summary collapse
-
#action_items ⇒ Array
The set of action items for this resource.
-
#action_items? ⇒ Boolean
Used by active_admin Base view.
-
#action_items_for(action, render_context = nil) ⇒ Array
Returns a set of action items to display for a specific controller action.
-
#add_action_item(name, options = {}, &block) ⇒ Object
Add a new action item to a resource.
-
#clear_action_items! ⇒ Object
Clears all the existing action items for this resource.
-
#initialize(*args) ⇒ Object
Adds the default action items to a resource when it’s initialized.
- #remove_action_item(name) ⇒ Object
Instance Method Details
#action_items ⇒ Array
Returns The set of action items for this resource.
16 17 18 |
# File 'lib/active_admin/resource/action_items.rb', line 16 def action_items @action_items ||= [] end |
#action_items? ⇒ Boolean
Used by active_admin Base view
52 53 54 |
# File 'lib/active_admin/resource/action_items.rb', line 52 def action_items? !!@action_items && @action_items.any? end |
#action_items_for(action, render_context = nil) ⇒ Array
Returns a set of action items to display for a specific controller action
42 43 44 |
# File 'lib/active_admin/resource/action_items.rb', line 42 def action_items_for(action, render_context = nil) action_items.select { |item| item.display_on? action, render_context }.sort_by(&:priority) end |
#add_action_item(name, options = {}, &block) ⇒ Object
Add a new action item to a resource
29 30 31 |
# File 'lib/active_admin/resource/action_items.rb', line 29 def add_action_item(name, = {}, &block) self.action_items << ActiveAdmin::ActionItem.new(name, , &block) end |
#clear_action_items! ⇒ Object
Clears all the existing action items for this resource
47 48 49 |
# File 'lib/active_admin/resource/action_items.rb', line 47 def clear_action_items! @action_items = [] end |
#initialize(*args) ⇒ Object
Adds the default action items to a resource when it’s initialized
10 11 12 13 |
# File 'lib/active_admin/resource/action_items.rb', line 10 def initialize(*args) super add_default_action_items end |
#remove_action_item(name) ⇒ Object
33 34 35 |
# File 'lib/active_admin/resource/action_items.rb', line 33 def remove_action_item(name) self.action_items.delete_if { |item| item.name == name } end |