comparison app/helpers/projects_helper.rb @ 69:dc22c3eb3c81 luisf

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.
author luisf
date Mon, 06 Dec 2010 18:12:52 +0000
parents 60c0a4e08e09
children 1412841d48a3
comparison
equal deleted inserted replaced
68:60c0a4e08e09 69:dc22c3eb3c81
88 # as a nested set of unordered lists 88 # as a nested set of unordered lists
89 # The given collection may be a subset of the whole project tree 89 # The given collection may be a subset of the whole project tree
90 # (eg. some intermediate nodes are private and can not be seen) 90 # (eg. some intermediate nodes are private and can not be seen)
91 def render_my_project_hierarchy(projects) 91 def render_my_project_hierarchy(projects)
92 s = '' 92 s = ''
93
94 a = ''
95
96 # Flag to tell if user has any projects
97 t = FALSE
93 98
94 if projects.any? 99 if projects.any?
95 ancestors = [] 100 ancestors = []
96 original_project = @project 101 original_project = @project
97 projects.each do |project| 102 projects.each do |project|
98 # set the project environment to please macros. 103 # set the project environment to please macros.
99 104
100 @project = project 105 @project = project
101 106
102 if User.current.member_of?(project): 107 if User.current.member_of?(project):
108
109 t = TRUE
103 110
104 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) 111 if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
105 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" 112 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
106 else 113 else
107 ancestors.pop 114 ancestors.pop
121 end 128 end
122 end 129 end
123 s << ("</li></ul>\n" * ancestors.size) 130 s << ("</li></ul>\n" * ancestors.size)
124 @project = original_project 131 @project = original_project
125 end 132 end
126 s 133
134 if t == TRUE
135 a << "<h2>"
136 a << l("label_my_project_plural")
137 a << "</h2>"
138 a << s
139 else
140 a = s
141 end
142
143 a
127 end 144 end
128 145
129 # Renders a tree of projects where the current DOES NOT belong 146 # Renders a tree of projects where the current DOES NOT belong
130 # as a nested set of unordered lists 147 # as a nested set of unordered lists
131 # The given collection may be a subset of the whole project tree 148 # The given collection may be a subset of the whole project tree
164 end 181 end
165 182
166 s << ("</li></ul>\n" * ancestors.size) 183 s << ("</li></ul>\n" * ancestors.size)
167 @project = original_project 184 @project = original_project
168 end 185 end
186
187
169 s 188 s
170 end 189 end
171 190
172 191
173 192