|
|
@@ -51,38 +51,15 @@ module ProjectsHelper |
|
|
|
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') |
|
|
|
end |
|
|
|
|
|
|
|
# Renders a tree of projects as a nested set of unordered lists |
|
|
|
# The given collection may be a subset of the whole project tree |
|
|
|
# (eg. some intermediate nodes are private and can not be seen) |
|
|
|
# Renders the projects index |
|
|
|
def render_project_hierarchy(projects) |
|
|
|
s = '' |
|
|
|
if projects.any? |
|
|
|
ancestors = [] |
|
|
|
original_project = @project |
|
|
|
projects.each do |project| |
|
|
|
# set the project environment to please macros. |
|
|
|
@project = project |
|
|
|
if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) |
|
|
|
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" |
|
|
|
else |
|
|
|
ancestors.pop |
|
|
|
s << "</li>" |
|
|
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) |
|
|
|
ancestors.pop |
|
|
|
s << "</ul></li>\n" |
|
|
|
end |
|
|
|
end |
|
|
|
classes = (ancestors.empty? ? 'root' : 'child') |
|
|
|
s << "<li class='#{classes}'><div class='#{classes}'>" + |
|
|
|
link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") |
|
|
|
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? |
|
|
|
s << "</div>\n" |
|
|
|
ancestors << project |
|
|
|
render_project_nested_lists(projects) do |project| |
|
|
|
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") |
|
|
|
if project.description.present? |
|
|
|
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') |
|
|
|
end |
|
|
|
s << ("</li></ul>\n" * ancestors.size) |
|
|
|
@project = original_project |
|
|
|
s |
|
|
|
end |
|
|
|
s.html_safe |
|
|
|
end |
|
|
|
|
|
|
|
# Returns a set of options for a select field, grouped by project. |