Permalink
Browse files

Deprecate Navigation.max_visible_tabs option as navigation is a verti…

…cal list now, fixes #478
  • Loading branch information...
1 parent 2e9202d commit 31e7c93d3bde00005fb6d5112b3d5ea03ff70f3b @kaapa kaapa committed Jun 21, 2011
Showing with 7 additions and 12 deletions.
  1. +3 −12 app/views/rails_admin/main/_navigation.html.haml
  2. +4 −0 lib/rails_admin/config/sections/navigation.rb
@@ -1,15 +1,13 @@
--# FIXME: not sure what models with children will look like with the activo theme, but I doubt it will be pretty.
--# Now that we are listing these vertically, it may be less necessary to hide models in dropdowns anyway.
+-# FIXME: models with children doesn't look pretty.
-# Also perhaps there's a better place for the following setup code - a before_filter perhaps?
- models = RailsAdmin::Config.visible_models.select { |model| authorized?(:list, model.abstract_model) }
- root_models = models.select { |model| model.parent == :root }
-- max_visible_tabs = (root_models.length == models.length ? RailsAdmin::Config::Sections::Navigation.max_visible_tabs : root_models.length)
%ul#nav.navigation
%li{:class => ("active" if @page_type == "dashboard")}
= link_to(t("admin.dashboard.name"), rails_admin_dashboard_path)
- - root_models[0..max_visible_tabs-1].each do |model|
+ - root_models.each do |model|
- children = [model] + models.select { |m| m.parent.to_s == model.abstract_model.model.to_s }
- tab_titles = children.map { |child| child.abstract_model.pretty_name.downcase }
%li{:class => "#{"active" if tab_titles.include? @page_type} #{"more" unless children.empty?}"}
@@ -20,11 +18,4 @@
%ul
- children.each_with_index do |child, index|
%li{:class => ("active" if @page_type == tab_titles[index])}
- = link_to(child.label.pluralize, rails_admin_list_path(:model_name => child.abstract_model.to_param))
- - if root_models.size > max_visible_tabs
- %li.more.plus
- %a{:href => "#"} »
- %ul
- - models[max_visible_tabs..root_models.size].each do |model|
- %li{:class => ("active" if @page_type == model.abstract_model.pretty_name.downcase)}
- = link_to(model.label.pluralize, rails_admin_list_path(:model_name => model.abstract_model.to_param))
+ = link_to(child.label.pluralize, rails_admin_list_path(:model_name => child.abstract_model.to_param))
@@ -8,7 +8,11 @@ module Sections
class Navigation < RailsAdmin::Config::Base
# Defines the number of tabs to be renderer in the main navigation.
# Rest of the links will be rendered to a drop down menu.
+ # NOTE: "max_visible_tabs" is deprecated
+ # FIXME: remove this after giving people an appropriate time
+ # to change their code.
register_class_option(:max_visible_tabs) do
+ ActiveSupport::Deprecation.warn("Navigation.max_visible_tabs configuration option is deprecated", caller)
5
end
end

0 comments on commit 31e7c93

Please sign in to comment.