Revision 443:350acce374a2 app/helpers
| app/helpers/projects_helper.rb | ||
|---|---|---|
| 23 | 23 |
|
| 24 | 24 |
def project_settings_tabs |
| 25 | 25 |
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
| 26 |
{:name => 'overview', :action => :edit_project, :partial => 'projects/settings/overview', :label => :label_welcome_page},
|
|
| 26 | 27 |
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
| 27 | 28 |
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
| 28 | 29 |
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
| ... | ... | |
| 49 | 50 |
content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id')
|
| 50 | 51 |
end |
| 51 | 52 |
|
| 53 |
def render_project_short_description(project) |
|
| 54 |
s = '' |
|
| 55 |
if (project.short_description) |
|
| 56 |
s << "<div class='description'>" |
|
| 57 |
s << textilizable(project.short_description, :project => project).gsub(/<[^>]+>/, '') |
|
| 58 |
s << "</div>" |
|
| 59 |
end |
|
| 60 |
s |
|
| 61 |
end |
|
| 62 |
|
|
| 52 | 63 |
# Renders a tree of projects as a nested set of unordered lists |
| 53 | 64 |
# The given collection may be a subset of the whole project tree |
| 54 | 65 |
# (eg. some intermediate nodes are private and can not be seen) |
| ... | ... | |
| 73 | 84 |
classes = (ancestors.empty? ? 'root' : 'child') |
| 74 | 85 |
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
| 75 | 86 |
link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
| 76 |
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
|
| 87 |
s << render_project_short_description(project)
|
|
| 77 | 88 |
s << "</div>\n" |
| 78 | 89 |
ancestors << project |
| 79 | 90 |
end |
| ... | ... | |
| 84 | 95 |
end |
| 85 | 96 |
|
| 86 | 97 |
|
| 98 |
def render_my_project_in_hierarchy(project) |
|
| 99 |
|
|
| 100 |
s = '' |
|
| 101 |
|
|
| 102 |
if User.current.member_of?(project) |
|
| 103 |
|
|
| 104 |
# set the project environment to please macros. |
|
| 105 |
@project = project |
|
| 106 |
|
|
| 107 |
classes = (project.root? ? 'root' : 'child') |
|
| 108 |
|
|
| 109 |
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
|
| 110 |
link_to_project(project, {}, :class => "project my-project")
|
|
| 111 |
if project.is_public? |
|
| 112 |
s << " <span class='public'>" << l("field_is_public") << "</span>"
|
|
| 113 |
else |
|
| 114 |
s << " <span class='private'>" << l("field_is_private") << "</span>"
|
|
| 115 |
end |
|
| 116 |
s << render_project_short_description(project) |
|
| 117 |
s << "</div>\n" |
|
| 118 |
|
|
| 119 |
cs = '' |
|
| 120 |
project.children.each do |child| |
|
| 121 |
cs << render_my_project_in_hierarchy(child) |
|
| 122 |
end |
|
| 123 |
|
|
| 124 |
if cs != '' |
|
| 125 |
s << "<ul class='projects'>\n" << cs << "</ul>\n"; |
|
| 126 |
end |
|
| 127 |
|
|
| 128 |
end |
|
| 129 |
|
|
| 130 |
s |
|
| 131 |
|
|
| 132 |
end |
|
| 133 |
|
|
| 87 | 134 |
# Renders a tree of projects where the current user belongs |
| 88 | 135 |
# as a nested set of unordered lists |
| 89 | 136 |
# The given collection may be a subset of the whole project tree |
| 90 | 137 |
# (eg. some intermediate nodes are private and can not be seen) |
| 91 | 138 |
def render_my_project_hierarchy(projects) |
| 139 |
|
|
| 92 | 140 |
s = '' |
| 93 | 141 |
|
| 94 |
a = ''
|
|
| 142 |
original_project = @project
|
|
| 95 | 143 |
|
| 96 |
# Flag to tell if user has any projects |
|
| 97 |
t = FALSE |
|
| 98 |
|
|
| 99 |
if projects.any? |
|
| 100 |
ancestors = [] |
|
| 101 |
original_project = @project |
|
| 102 |
projects.each do |project| |
|
| 103 |
# set the project environment to please macros. |
|
| 104 |
|
|
| 105 |
@project = project |
|
| 106 |
|
|
| 107 |
if User.current.member_of?(project): |
|
| 108 |
|
|
| 109 |
t = TRUE |
|
| 110 |
|
|
| 111 |
if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) |
|
| 112 |
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
|
|
| 113 |
else |
|
| 114 |
ancestors.pop |
|
| 115 |
s << "</li>" |
|
| 116 |
while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) |
|
| 117 |
ancestors.pop |
|
| 118 |
s << "</ul></li>\n" |
|
| 119 |
end |
|
| 120 |
end |
|
| 121 |
|
|
| 122 |
classes = (ancestors.empty? ? 'root' : 'child') |
|
| 123 |
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
|
| 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 |
|
| 130 |
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
|
| 131 |
s << "</div>\n" |
|
| 132 |
ancestors << project |
|
| 133 |
end |
|
| 134 |
end |
|
| 135 |
s << ("</li></ul>\n" * ancestors.size)
|
|
| 136 |
@project = original_project |
|
| 144 |
projects.each do |project| |
|
| 145 |
if project.root? || !projects.include?(project.parent) |
|
| 146 |
s << render_my_project_in_hierarchy(project) |
|
| 147 |
end |
|
| 137 | 148 |
end |
| 138 | 149 |
|
| 139 |
if t == TRUE |
|
| 150 |
@project = original_project |
|
| 151 |
|
|
| 152 |
if s != '' |
|
| 153 |
a = '' |
|
| 140 | 154 |
a << "<h2>" |
| 141 | 155 |
a << l("label_my_project_plural")
|
| 142 | 156 |
a << "</h2>" |
| 157 |
a << "<ul class='projects root'>\n" |
|
| 143 | 158 |
a << s |
| 144 |
else
|
|
| 145 |
a = s
|
|
| 159 |
a << "</ul>\n"
|
|
| 160 |
s = a
|
|
| 146 | 161 |
end |
| 162 |
|
|
| 163 |
s |
|
| 147 | 164 |
|
| 148 |
a |
|
| 149 | 165 |
end |
| 150 | 166 |
|
| 151 | 167 |
# Renders a tree of projects that the current user does not belong |
| ... | ... | |
| 198 | 214 |
s << " no_description" if project.description.blank? |
| 199 | 215 |
s << "'>" << link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}");
|
| 200 | 216 |
s << "</div>" |
| 201 |
unless project.description.blank? |
|
| 202 |
s << "<div class='wiki description'>" |
|
| 203 |
s << textilizable(project.short_description, :project => project) |
|
| 204 |
s << "</div>" |
|
| 205 |
end |
|
| 217 |
s << render_project_short_description(project) |
|
| 206 | 218 |
|
| 207 | 219 |
s << "<td class='managers' align=top>" |
| 208 | 220 |
|
| ... | ... | |
| 230 | 242 |
s << "</tr>" |
| 231 | 243 |
|
| 232 | 244 |
project.children.each do |child| |
| 233 |
s << render_project_in_table(child, oddeven, level + 1) |
|
| 245 |
if child.is_public? or User.current.member_of?(child) |
|
| 246 |
s << render_project_in_table(child, oddeven, level + 1) |
|
| 247 |
end |
|
| 234 | 248 |
end |
| 235 | 249 |
|
| 236 | 250 |
s |
Also available in: Unified diff