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