Permalink
Browse files

Let's use instance variables.

  • Loading branch information...
1 parent 6417e1a commit 9d73c36c9440b7bde6d34dfe00bac2a71005f6f0 @gunn gunn committed Oct 2, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 app/helpers/rails_admin/application_helper.rb
@@ -47,15 +47,17 @@ def main_navigation
nodes_stack.group_by(&:navigation_label).map do |navigation_label, nodes|
li_stack = nodes.select{|n| n.parent.nil? || !n.parent.to_s.in?(nodes_stack.map{|c| c.abstract_model.model_name }) }.map do |node|
- %{
- <li data-model="#{node.abstract_model.to_param}">
- <a class="pjax" href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => node.abstract_model.to_param)}">#{node.label_plural}</a>
+ model_param = node.abstract_model.to_param
+
+ %{<li data-model="#{model_param}">
+ <a class="pjax" href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => model_param)}">#{node.label_plural}</a>
</li>
#{navigation(nodes_stack, nodes_stack.select{|n| n.parent.to_s == node.abstract_model.model_name}, 1)}
}
end.join
- %{<li class='nav-header'>#{navigation_label || t('admin.misc.navigation')}</li>#{li_stack.presence}}
+ label = navigation_label || t('admin.misc.navigation')
+ %{<li class='nav-header'>#{label}</li>#{li_stack.presence}}
end.join.html_safe
end
@@ -64,14 +66,16 @@ def static_navigation
content_tag(:li, link_to(title.to_s, url, :target => '_blank'))
end.join
- %{<li class='nav-header'>#{RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')}</li>#{li_stack.presence}}.html_safe
+ label = RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')
+ %{<li class='nav-header'>#{label}</li>#{li_stack.presence}}.html_safe
end
def navigation nodes_stack, nodes, level
nodes.map do |node|
- %{
- <li data-model="#{node.abstract_model.to_param}">
- <a class="pjax nav-level-#{level}" href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => node.abstract_model.to_param)}">#{node.label_plural}</a>
+ model_param = node.abstract_model.to_param
+
+ %{<li data-model="#{node.abstract_model.to_param}">
+ <a class="pjax nav-level-#{level}" href="#{url_for(:action => :index, :controller => 'rails_admin/main', :model_name => model_param)}">#{node.label_plural}</a>
</li>
#{navigation(nodes_stack, nodes_stack.select{ |n| n.parent.to_s == node.abstract_model.model_name}, level + 1)}
}

0 comments on commit 9d73c36

Please sign in to comment.