diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 17:24:22 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 17:24:22 +0000 |
commit | a19a0d7b9278ae8666971e5f004013ecaa3a9cf8 (patch) | |
tree | 5a6c2af392fcecd3a6617c5e8852919488c756e0 /app | |
parent | 17a3f9e44c1509dbaebf478ec82ef2559d4e40cf (diff) | |
download | redmine-a19a0d7b9278ae8666971e5f004013ecaa3a9cf8.tar.gz redmine-a19a0d7b9278ae8666971e5f004013ecaa3a9cf8.zip |
Subprojects are now grouped by projects in the 'Projects' top navigation drop-down menu.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@703 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/views/layouts/_projects_menu.rhtml | 12 | ||||
-rw-r--r-- | app/views/layouts/base.rhtml | 14 |
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(('» ' + 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? %> |