summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/project.rb4
-rw-r--r--app/views/layouts/_projects_menu.rhtml12
-rw-r--r--app/views/layouts/base.rhtml14
3 files changed, 18 insertions, 12 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index eeeaa9fd4..2eaa0f733 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -116,6 +116,10 @@ class Project < ActiveRecord::Base
def all_custom_fields
@all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
end
+
+ def <=>(project)
+ name <=> project.name
+ end
protected
def validate
diff --git a/app/views/layouts/_projects_menu.rhtml b/app/views/layouts/_projects_menu.rhtml
new file mode 100644
index 000000000..3204d5fbc
--- /dev/null
+++ b/app/views/layouts/_projects_menu.rhtml
@@ -0,0 +1,12 @@
+<div id="menuAllProjects" class="menu" onmouseover="menuMouseover(event)">
+ <%= link_to l(:label_project_all), {:controller => 'projects' }, :class => "menuItem" %>
+
+ <% user_projects_by_root = User.current.projects.find(:all, :include => :parent, :limit => 20).group_by(&:root) %>
+ <% user_projects_by_root.keys.sort.each do |root| %>
+ <%= link_to root.name, {:controller => 'projects', :action => 'show', :id => root}, :class => "menuItem" %>
+ <% user_projects_by_root[root].sort.each do |project| %>
+ <% next if project == root %>
+ <%= link_to(('&#187; ' + project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "menuItem") %>
+ <% end %>
+ <% end %>
+</div>
diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml
index 1beb51ca9..acce89d44 100644
--- a/app/views/layouts/base.rhtml
+++ b/app/views/layouts/base.rhtml
@@ -64,18 +64,8 @@
</ul>
</div>
- <% if User.current.admin? %>
- <%= render :partial => 'admin/menu' %>
- <% end %>
-
- <% if User.current.memberships.any? %>
- <div id="menuAllProjects" class="menu" onmouseover="menuMouseover(event)">
- <%= link_to l(:label_project_all), {:controller => 'projects' }, :class => "menuItem" %>
- <% User.current.memberships.find(:all, :limit => 20).each do |membership| %>
- <%= link_to membership.project.name, {:controller => 'projects',:action => 'show', :id => membership.project }, :class => "menuItem" %>
- <% end %>
- </div>
- <% end %>
+ <%= render(:partial => 'admin/menu') if User.current.admin? %>
+ <%= render(:partial => 'layouts/projects_menu') if User.current.memberships.any? %>
<div id="subcontent">
<% if @project && !@project.new_record? %>