# HG changeset patch # User luisf # Date 1291657843 0 # Node ID 60c0a4e08e099a6bce4f5095f2dc7ed02b657582 # Parent 29d087fde14247a8ab45335ca7976d55f0477bf7 Feature #35: The projects page now is separated in "My Projects" and "Other Projects". diff -r 29d087fde142 -r 60c0a4e08e09 app/helpers/projects_helper.rb --- a/app/helpers/projects_helper.rb Mon Dec 06 13:48:52 2010 +0000 +++ b/app/helpers/projects_helper.rb Mon Dec 06 17:50:43 2010 +0000 @@ -83,6 +83,94 @@ s 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(projects) + s = '' + + if projects.any? + ancestors = [] + original_project = @project + projects.each do |project| + # set the project environment to please macros. + + @project = project + + if User.current.member_of?(project): + + if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) + s << "\n" + end + end + + classes = (ancestors.empty? ? 'root' : 'child') + s << "
  • " + + link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") + s << "
    #{textilizable(project.short_description, :project => project)}
    " unless project.description.blank? + s << "
    \n" + ancestors << project + end + end + s << ("
  • \n" * ancestors.size) + @project = original_project + end + s + end + + # Renders a tree of projects where the current DOES NOT belong + # 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_other_project_hierarchy(projects) + s = '' + + if projects.any? + ancestors = [] + original_project = @project + projects.each do |project| + # set the project environment to please macros. + + @project = project + + if not User.current.member_of?(project): + + if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) + s << "\n" + end + end + + classes = (ancestors.empty? ? 'root' : 'child') + s << "
  • " + + link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") + s << "
    #{textilizable(project.short_description, :project => project)}
    " unless project.description.blank? + s << "
    \n" + ancestors << project + end + end + + s << ("
  • \n" * ancestors.size) + @project = original_project + end + s + end + + + # Returns a set of options for a select field, grouped by project. def version_options_for_select(versions, selected=nil) grouped = Hash.new {|h,k| h[k] = []} diff -r 29d087fde142 -r 60c0a4e08e09 app/views/projects/index.rhtml --- a/app/views/projects/index.rhtml Mon Dec 06 13:48:52 2010 +0000 +++ b/app/views/projects/index.rhtml Mon Dec 06 17:50:43 2010 +0000 @@ -9,9 +9,12 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> -

    <%=l(:label_project_plural)%>

    +

    <%=l(:label_my_project_plural)%>

    +<%= render_my_project_hierarchy(@projects)%> -<%= render_project_hierarchy(@projects)%> + +

    <%=l(:label_other_project_plural)%>

    +<%= render_other_project_hierarchy(@projects)%> <% if User.current.logged? %>

    @@ -19,6 +22,13 @@

    <% end %> + + + + + + + <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <% end %> diff -r 29d087fde142 -r 60c0a4e08e09 config/locales/en.yml --- a/config/locales/en.yml Mon Dec 06 13:48:52 2010 +0000 +++ b/config/locales/en.yml Mon Dec 06 17:50:43 2010 +0000 @@ -436,6 +436,8 @@ label_project: Project label_project_new: New project label_project_plural: Projects + label_my_project_plural: My Projects + label_other_project_plural: Other Projects label_x_projects: zero: no projects one: 1 project