diff --git a/nested_projects/app/helpers/application_helper.rb b/nested_projects/app/helpers/application_helper.rb index 56db00855..82905ebcb 100644 --- a/nested_projects/app/helpers/application_helper.rb +++ b/nested_projects/app/helpers/application_helper.rb @@ -147,6 +147,34 @@ module ApplicationHelper end content end + + # Renders the project quick-jump box + def render_project_jump_box + # Retrieve them now to avoid a COUNT query + projects = User.current.projects.all + if projects.any? + s = '' + end + end + + # Yields the given block for each project with its level in the tree + def project_tree(projects, &block) + ancestors = [] + projects.sort_by(&:lft).each do |project| + while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) + ancestors.pop + end + yield project, ancestors.size + ancestors << project + end + end # Truncates and returns the string as a single line def truncate_single_line(string, *args) diff --git a/nested_projects/app/views/layouts/_project_selector.rhtml b/nested_projects/app/views/layouts/_project_selector.rhtml deleted file mode 100644 index cffc85f7e..000000000 --- a/nested_projects/app/views/layouts/_project_selector.rhtml +++ /dev/null @@ -1,12 +0,0 @@ -<% user_projects_by_root = User.current.projects.find(:all).group_by(&:root) %> - diff --git a/nested_projects/app/views/layouts/base.rhtml b/nested_projects/app/views/layouts/base.rhtml index b146d615e..1d434656f 100644 --- a/nested_projects/app/views/layouts/base.rhtml +++ b/nested_projects/app/views/layouts/base.rhtml @@ -34,7 +34,7 @@ <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>: <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %> <% end %> - <%= render :partial => 'layouts/project_selector' if User.current.memberships.any? %> + <%= render_project_jump_box %>