Permalink
Browse files

Added Navigation Icons

You can specify `navigation_icon 'icon-something'` to your model
configuration and it the icon will appear in the main navigation menu.
  • Loading branch information...
1 parent bb64c94 commit fd753c0133e9afc26b5e32ca1940149458079f73 Nicolas Lupien committed Apr 4, 2013
Showing with 6 additions and 1 deletion.
  1. +2 −1 app/helpers/rails_admin/application_helper.rb
  2. +4 −0 lib/rails_admin/config/model.rb
@@ -79,9 +79,10 @@ def navigation nodes_stack, nodes, level=0
model_param = node.abstract_model.to_param
url = url_for(:action => :index, :controller => 'rails_admin/main', :model_name => model_param)
level_class = " nav-level-#{level}" if level > 0
+ nav_icon = node.navigation_icon ? %{<i class="#{node.navigation_icon}"></i>}.html_safe : ''
li = content_tag :li, "data-model"=>model_param do
- link_to node.label_plural, url, :class => "pjax#{level_class}"
+ link_to nav_icon + node.label_plural, url, :class => "pjax#{level_class}"
end
li + navigation(nodes_stack, nodes_stack.select{ |n| n.parent.to_s == node.abstract_model.model_name}, level+1)
end.join.html_safe
@@ -82,6 +82,10 @@ def pluralize(count)
@navigation_label ||= (parent_module = abstract_model.model.parent) != Object ? parent_module.to_s : nil
end
+ register_instance_option :navigation_icon do
+ nil
+ end
+
# Act as a proxy for the base section configuration that actually
# store the configurations.
def method_missing(m, *args, &block)

0 comments on commit fd753c0

Please sign in to comment.