Class: AbAdmin::Menu::Group

Inherits:
BaseGroup show all
Defined in:
lib/ab_admin/menu/group.rb

Instance Method Summary collapse

Methods inherited from BaseGroup

#group, #link, #model, #render_nested

Methods included from Utils::EvalHelpers

#call_method_or_proc_on, #evaluate_method

Constructor Details

#initialize(title, options, &block) ⇒ Group

Returns a new instance of Group.



4
5
6
7
8
9
10
# File 'lib/ab_admin/menu/group.rb', line 4

def initialize(title, options, &block)
  @menu_tree = []
  @raw_title = title
  @title = title.is_a?(Symbol) ? I18n.t(title, scope: [:admin, :navigation]) : title
  @options = options
  instance_eval &block if block_given?
end

Instance Method Details

#render(template) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ab_admin/menu/group.rb', line 12

def render(template)
  return if @options[:if] && !call_method_or_proc_on(template, @options[:if])
  return if @options[:unless] && call_method_or_proc_on(template, @options[:unless])

  wrapper_class = "dropdown-wrap-#{@raw_title}" if @raw_title.is_a?(Symbol)
  <<-HTML.html_safe
<li class="dropdown #{wrapper_class}">
  <a class="dropdown-toggle" href="#{@options[:url] || '#'}" >#{title(template)}<b class="caret"></b></a>
  <ul class="dropdown-menu">#{render_nested(template)}</ul>
<li>
  HTML
end