Module: MenuHelper

Defined in:
app/helpers/menu_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_menu(menu) ⇒ Object

build menu to site

Parameters:

  • menu

    title items



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/menu_helper.rb', line 8

def build_menu(menu)
  raw %Q{
    <li id="fat-menu" class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        #{t(menu[:title]+".link")} <b class="caret"></b>
      </a>
      <ul class="dropdown-menu">
        #{build_menu_items(menu)}
      </ul>
    </li>
      }
end

#build_menu_adminObject



51
52
53
# File 'app/helpers/menu_helper.rb', line 51

def build_menu_admin()
  build_menu(GUARACRM::Menus::ADMINISTRATION)
end

#build_menu_items(menu) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/menu_helper.rb', line 21

def build_menu_items(menu)
  returns = ""
  menu[:items].each do |item|
    rails_model = item.to_s.titlecase.gsub(' ','').singularize.to_sym
    
    if can? :read, rails_model
      
      if (item.is_a? Array)
        item_title = item[0]
        path = eval item[1]
      else
        item_title = item
        menu_path = []
        menu_path << menu[:namespace] if !menu[:namespace].empty?
        menu_path << item
        menu_path << "path"
        path = eval(menu_path.join('_')+"()")
			end        
			
			returns += %Q{ <li>#{ link_to t(item_title.to_s+".title"), path }</li> }

    end
  end
  returns
end

#build_menu_maintenceObject



47
48
49
# File 'app/helpers/menu_helper.rb', line 47

def build_menu_maintence()
  build_menu(GUARACRM::Menus::MAINTENCE)
end