Class: ActiveAdmin::Views::DropdownMenu

Inherits:
Component
  • Object
show all
Defined in:
lib/active_admin/views/components/dropdown_menu.rb

Overview

Action List - A button with a drop down menu of links

Creating a new action list:

dropdown_menu "Administration" do
  item "Edit Details", edit_details_path
  item "Edit My Account", 
end

This will create a button with the label “Administration” and a drop down once clicked with 2 options.

Instance Method Summary collapse

Instance Method Details

#build(name, options = {}) ⇒ Object

Build a new action list

Parameters:

  • name (String)

    The name to display in the button

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

    A set of options that get passed along to to the parent dom element.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_admin/views/components/dropdown_menu.rb', line 26

def build(name, options = {})
  options = options.dup

  # Easily set options for the button or menu
  button_options = options.delete(:button) || {}
  menu_options = options.delete(:menu) || {}

  @button = build_button(name, button_options)
  @menu = build_menu(menu_options)

  super(options)
end

#item(*args, **kwargs) ⇒ Object



39
40
41
42
43
# File 'lib/active_admin/views/components/dropdown_menu.rb', line 39

def item(*args, **kwargs)
  within @menu do
    li link_to(*args, **kwargs)
  end
end