Mercurial > hg > soundsoftware-site
comparison app/helpers/projects_helper.rb @ 124:bc91f2025d05 cannam
Make the project list into a sortable table with a little more information in it
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Tue, 18 Jan 2011 17:02:06 +0000 |
parents | 1412841d48a3 |
children | ca48d8b6f55d |
comparison
equal
deleted
inserted
replaced
123:605adf7e1735 | 124:bc91f2025d05 |
---|---|
141 end | 141 end |
142 | 142 |
143 a | 143 a |
144 end | 144 end |
145 | 145 |
146 # Renders a tree of projects where the current DOES NOT belong | 146 # Renders a tree of projects that the current user does not belong |
147 # as a nested set of unordered lists | 147 # to, or of all projects if the current user is not logged in. The |
148 # The given collection may be a subset of the whole project tree | 148 # given collection may be a subset of the whole project tree |
149 # (eg. some intermediate nodes are private and can not be seen) | 149 # (eg. some intermediate nodes are private and can not be seen). We |
150 def render_other_project_hierarchy(projects) | 150 # are potentially interested in various things: the project name, |
151 a = '' | 151 # description, manager(s), creation date, last activity date, |
152 s = '' | 152 # general activity level, whether there is anything actually hosted |
153 | 153 # here for the project, etc. |
154 # True if user has any projects (affects the heading used) | 154 def render_project_table(projects) |
155 t = FALSE | 155 |
156 | 156 s = "" |
157 if projects.any? | 157 s << "<div class='autoscroll'>" |
158 ancestors = [] | 158 s << "<table class='list projects'>" |
159 original_project = @project | 159 s << "<thead><tr>" |
160 projects.each do |project| | 160 |
161 # set the project environment to please macros. | 161 s << sort_header_tag('lft', :caption => l("field_name"), :default_order => 'desc') |
162 | 162 s << "<th class='managers'>" << l("label_managers") << "</th>" |
163 @project = project | 163 s << sort_header_tag('created_on', :default_order => 'desc') |
164 | 164 s << sort_header_tag('updated_on', :default_order => 'desc') |
165 if not User.current.member_of?(project): | 165 |
166 | 166 s << "</tr></thead><tbody>" |
167 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | 167 |
168 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | 168 ancestors = [] |
169 else | 169 original_project = @project |
170 ancestors.pop | 170 oddeven = 'even' |
171 s << "</li>" | 171 level = 0 |
172 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | 172 |
173 ancestors.pop | 173 projects.each do |project| |
174 s << "</ul></li>\n" | 174 |
175 # set the project environment to please macros. | |
176 | |
177 @project = project | |
178 | |
179 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | |
180 level = level + 1 | |
181 else | |
182 level = 0 | |
183 oddeven = cycle('odd','even') | |
184 ancestors.pop | |
185 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | |
186 ancestors.pop | |
187 end | |
188 end | |
189 | |
190 classes = (ancestors.empty? ? 'root' : 'child') | |
191 | |
192 s << "<tr class='#{oddeven} #{classes} level#{level}'>" | |
193 s << "<td class='firstcol name hosted_here'>" << link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") << "</td>" | |
194 s << "<td class='managers'>" | |
195 | |
196 u = project.users_by_role | |
197 if u | |
198 u.keys.each do |r| | |
199 if r.allowed_to?(:edit_project) | |
200 mgrs = [] | |
201 u[r].sort.each do |m| | |
202 mgrs << link_to_user(m) | |
203 end | |
204 if mgrs.size < 3 | |
205 s << '<nobr>' << mgrs.join(', ') << '</nobr>' | |
206 else | |
207 s << mgrs.join(', ') | |
175 end | 208 end |
176 end | 209 end |
177 | 210 end |
178 classes = (ancestors.empty? ? 'root' : 'child') | 211 end |
179 s << "<li class='#{classes}'><div class='#{classes}'>" + | 212 |
180 link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") | 213 s << "</td>" |
181 s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? | 214 s << "<td class='created_on'>" << format_date(project.created_on) << "</td>" |
182 s << "</div>\n" | 215 s << "<td class='updated_on'>" << format_date(project.updated_on) << "</td>" |
183 ancestors << project | 216 |
184 else | 217 s << "</tr>" |
185 t = TRUE | 218 s << "<tr class='#{oddeven} #{classes}'>" |
186 end | 219 s << "<td class='firstcol wiki description'>" |
187 end | 220 s << textilizable(project.short_description, :project => project) unless project.description.blank? |
188 | 221 s << "</td>" |
189 s << ("</li></ul>\n" * ancestors.size) | 222 s << "<td colspan=3> </td>" |
190 @project = original_project | 223 s << "</tr>" |
191 end | 224 |
192 | 225 ancestors << project |
193 if t == TRUE | 226 end |
194 a << "<h2>" | 227 |
195 a << l("label_other_project_plural") | 228 s << "</table>" |
196 a << "</h2>" | 229 |
197 a << s | 230 @project = original_project |
198 else | 231 |
199 a << "<h2>" | 232 s |
200 a << l("label_project_all") | |
201 a << "</h2>" | |
202 a << s | |
203 end | |
204 | |
205 a | |
206 end | 233 end |
207 | 234 |
208 | 235 |
209 | 236 |
210 # Returns a set of options for a select field, grouped by project. | 237 # Returns a set of options for a select field, grouped by project. |