changeset 800:95b78e19e586 feature_14

Addresses (closes?) Feature #336
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 21 Nov 2011 17:40:25 +0000
parents 9f2bc483b7ec
children c8aec937ea53
files vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb
diffstat 2 files changed, 76 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml	Mon Nov 21 17:17:25 2011 +0000
+++ b/vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml	Mon Nov 21 17:40:25 2011 +0000
@@ -8,7 +8,7 @@
 <%  end%>
     <% if @user_projects %>  
     <div>
-      <%= render_my_project_hierarchy(@user_projects)%>
+      <%= render_my_project_hierarchy_with_tags(@user_projects)%>
     </div>
   <% end %>
 </fieldset>
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Mon Nov 21 17:17:25 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Mon Nov 21 17:40:25 2011 +0000
@@ -160,6 +160,81 @@
           s.join "\n"
         end
         
+        # Renders a tree of projects where the current user belongs
+        # as a nested set of unordered lists
+        # The given collection may be a subset of the whole project tree
+        # (eg. some intermediate nodes are private and can not be seen)
+        def render_my_project_hierarchy_with_tags(projects)
+
+          s = ''
+
+          original_project = @project
+
+          projects.each do |project|
+            if project.root? || !projects.include?(project.parent)
+              s << render_my_project_in_hierarchy_with_tags(project)
+            end
+          end
+
+          @project = original_project
+
+          if s != ''
+            a = ''
+            a << "<ul class='projects root'>\n"
+            a << s
+            a << "</ul>\n"
+            s = a
+          end
+
+          s
+
+        end
+        
+        
+        
+
+        def render_my_project_in_hierarchy_with_tags(project)
+
+          s = ''
+
+          if User.current.member_of?(project)
+
+            # set the project environment to please macros.
+            @project = project
+
+            classes = (project.root? ? 'root' : 'child')
+
+            s << "<li class='#{classes}'><div class='#{classes}'>" +
+              link_to_project(project, {}, :class => "project my-project")
+            if project.is_public?
+              s << " <span class='public'>" << l("field_is_public") << "</span>"
+            else
+              s << " <span class='private'>" << l("field_is_private") << "</span>"
+            end
+            s << render_project_short_description(project)
+
+            s << l(:tags) << ":&nbsp"
+            s << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ')
+
+            s << "</div>\n"
+
+            cs = ''
+            project.children.each do |child|
+              cs << render_my_project_in_hierarchy(child)
+            end
+
+            if cs != ''
+              s << "<ul class='projects'>\n" << cs << "</ul>\n";
+            end
+
+          end
+
+          s
+
+        end
+
+        
+        
         private
         
         # copied from search_helper. This one doesn't escape html or limit the text length