]> source.dussan.org Git - redmine.git/commitdiff
Subprojects are now grouped by projects in the 'Projects' top navigation drop-down...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 5 Sep 2007 17:24:22 +0000 (17:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 5 Sep 2007 17:24:22 +0000 (17:24 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@703 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
app/views/layouts/_projects_menu.rhtml [new file with mode: 0644]
app/views/layouts/base.rhtml

index eeeaa9fd410c8eadfb3266f4cc79c732e3542a66..2eaa0f733fd45a1b07fc02f555dee3a5441d0294 100644 (file)
@@ -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 (file)
index 0000000..3204d5f
--- /dev/null
@@ -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>
index 1beb51ca9b62b97bf9740eb008b189020a960d6d..acce89d44dc5df7cf50ce0d1efe41eeac9e7177e 100644 (file)
                </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? %>