# HG changeset patch # User luisf # Date 1291659172 0 # Node ID dc22c3eb3c8113a30b5522db60d6b88706fa21dd # Parent 60c0a4e08e099a6bce4f5095f2dc7ed02b657582 Feature #35: - Does not show the label "My Projects" if the user does not have any projects. - If the user is not signed in only shows the default Projects list. diff -r 60c0a4e08e09 -r dc22c3eb3c81 app/helpers/projects_helper.rb --- a/app/helpers/projects_helper.rb Mon Dec 06 17:50:43 2010 +0000 +++ b/app/helpers/projects_helper.rb Mon Dec 06 18:12:52 2010 +0000 @@ -90,6 +90,11 @@ # (eg. some intermediate nodes are private and can not be seen) def render_my_project_hierarchy(projects) s = '' + + a = '' + + # Flag to tell if user has any projects + t = FALSE if projects.any? ancestors = [] @@ -101,6 +106,8 @@ if User.current.member_of?(project): + t = TRUE + if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) s << "\n" * ancestors.size) @project = original_project end - s + + if t == TRUE + a << "

" + a << l("label_my_project_plural") + a << "

" + a << s + else + a = s + end + + a end # Renders a tree of projects where the current DOES NOT belong @@ -166,6 +183,8 @@ s << ("\n" * ancestors.size) @project = original_project end + + s end diff -r 60c0a4e08e09 -r dc22c3eb3c81 app/views/projects/index.rhtml --- a/app/views/projects/index.rhtml Mon Dec 06 17:50:43 2010 +0000 +++ b/app/views/projects/index.rhtml Mon Dec 06 18:12:52 2010 +0000 @@ -9,12 +9,20 @@ <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> -

<%=l(:label_my_project_plural)%>

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

<%=l(:label_other_project_plural)%>

+ <%= render_other_project_hierarchy(@projects)%> -

<%=l(:label_other_project_plural)%>

-<%= render_other_project_hierarchy(@projects)%> +<% else %> + +

<%=l(:label_project_plural)%>

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

@@ -23,12 +31,6 @@ <% end %> - - - - - - <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <% end %>