Sha256: 3a2ab5c78ca621b01c63817ef8fb631dcd0c66381132fb5e87266e31c1a64fb9
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# -*- encoding : utf-8 -*- module RademadeAdmin::MenuHelper def main_menu @model_infos = RademadeAdmin::Model::Graph.instance.root_models menu = collect_children menu.unshift({ :uri => url_for(:root), :name => 'Home', :ico => 'fa fa-home', :sub => [] }) menu end def active?(menu_item) if menu_item[:is_current] true else menu_item[:sub].each do |sub_item| if active?(sub_item) return true end end false end end private def collect_children(parent = nil) menu = [] @model_infos.each do |model_info| if model_info.parent_menu_item == parent uri = admin_list_uri(model_info) menu << { :uri => uri, :model_info => model_info, :sub => collect_children(model_info.model.to_s), :is_current => current_menu?(uri, model_info) } end end menu end def current_menu?(uri, model_info) model_info == @model_info or (not uri.nil? and current_page?(uri)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rademade_admin-0.0.3 | app/helpers/rademade_admin/menu_helper.rb |
rademade_admin-0.0.2 | app/helpers/rademade_admin/menu_helper.rb |