class ActiveAdmin::Views::MenuItem

Arbre component used to render ActiveAdmin::MenuItem

Attributes

label[R]
priority[R]
url[R]

Public Instance Methods

<=>(other) click to toggle source

Sorts by priority first, then alphabetically by label if needed.

# File lib/active_admin/views/components/menu_item.rb, line 38
def <=>(other)
  result = priority <=> other.priority
  result == 0 ? label <=> other.label : result
end
build(item, options = {}) click to toggle source
Calls superclass method
# File lib/active_admin/views/components/menu_item.rb, line 12
def build(item, options = {})
  super(options.merge(id: item.id))
  @label = helpers.render_in_context self, item.label
  @url = helpers.render_in_context self, item.url
  @priority = item.priority
  @submenu = nil

  add_class "current" if item.current? assigns[:current_tab]

  if url
    text_node link_to label, url, **item.html_options
  else
    span label, item.html_options
  end

  if item.items.any?
    add_class "has_nested"
    @submenu = menu(item)
  end
end
tag_name() click to toggle source
# File lib/active_admin/views/components/menu_item.rb, line 33
def tag_name
  "li"
end
to_s() click to toggle source
Calls superclass method
# File lib/active_admin/views/components/menu_item.rb, line 47
def to_s
  visible? ? super : ""
end
visible?() click to toggle source
# File lib/active_admin/views/components/menu_item.rb, line 43
def visible?
  url.nil? || real_url? || @submenu && @submenu.children.any?
end

Private Instance Methods

real_url?() click to toggle source

URL is not nil, empty, or ‘#’

# File lib/active_admin/views/components/menu_item.rb, line 54
def real_url?
  url && url.present? && url != "#"
end