@@ -195,6 +195,39 module ApplicationHelper | |||
|
195 | 195 | end |
|
196 | 196 | end |
|
197 | 197 | |
|
198 | # Renders a tree of projects as a nested set of unordered lists | |
|
199 | # The given collection may be a subset of the whole project tree | |
|
200 | # (eg. some intermediate nodes are private and can not be seen) | |
|
201 | def render_project_nested_lists(projects) | |
|
202 | s = '' | |
|
203 | if projects.any? | |
|
204 | ancestors = [] | |
|
205 | original_project = @project | |
|
206 | projects.each do |project| | |
|
207 | # set the project environment to please macros. | |
|
208 | @project = project | |
|
209 | if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | |
|
210 | s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | |
|
211 | else | |
|
212 | ancestors.pop | |
|
213 | s << "</li>" | |
|
214 | while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | |
|
215 | ancestors.pop | |
|
216 | s << "</ul></li>\n" | |
|
217 | end | |
|
218 | end | |
|
219 | classes = (ancestors.empty? ? 'root' : 'child') | |
|
220 | s << "<li class='#{classes}'><div class='#{classes}'>" | |
|
221 | s << h(block_given? ? yield(project) : project.name) | |
|
222 | s << "</div>\n" | |
|
223 | ancestors << project | |
|
224 | end | |
|
225 | s << ("</li></ul>\n" * ancestors.size) | |
|
226 | @project = original_project | |
|
227 | end | |
|
228 | s.html_safe | |
|
229 | end | |
|
230 | ||
|
198 | 231 | def render_page_hierarchy(pages, node=nil, options={}) |
|
199 | 232 | content = '' |
|
200 | 233 | if pages[node] |
@@ -51,38 +51,15 module ProjectsHelper | |||
|
51 | 51 | content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | # Renders a tree of projects as a nested set of unordered lists | |
|
55 | # The given collection may be a subset of the whole project tree | |
|
56 | # (eg. some intermediate nodes are private and can not be seen) | |
|
54 | # Renders the projects index | |
|
57 | 55 | def render_project_hierarchy(projects) |
|
58 | s = '' | |
|
59 | if projects.any? | |
|
60 | ancestors = [] | |
|
61 | original_project = @project | |
|
62 | projects.each do |project| | |
|
63 | # set the project environment to please macros. | |
|
64 | @project = project | |
|
65 | if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | |
|
66 | s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | |
|
67 | else | |
|
68 | ancestors.pop | |
|
69 | s << "</li>" | |
|
70 | while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | |
|
71 | ancestors.pop | |
|
72 | s << "</ul></li>\n" | |
|
73 | end | |
|
74 | end | |
|
75 | classes = (ancestors.empty? ? 'root' : 'child') | |
|
76 | s << "<li class='#{classes}'><div class='#{classes}'>" + | |
|
77 | link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") | |
|
78 | s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? | |
|
79 | s << "</div>\n" | |
|
80 | ancestors << project | |
|
56 | render_project_nested_lists(projects) do |project| | |
|
57 | s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") | |
|
58 | if project.description.present? | |
|
59 | s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') | |
|
81 | 60 | end |
|
82 | s << ("</li></ul>\n" * ancestors.size) | |
|
83 | @project = original_project | |
|
61 | s | |
|
84 | 62 | end |
|
85 | s.html_safe | |
|
86 | 63 | end |
|
87 | 64 | |
|
88 | 65 | # Returns a set of options for a select field, grouped by project. |
General Comments 0
You need to be logged in to leave comments.
Login now