| 9 |
9 |
end
|
| 10 |
10 |
end
|
| 11 |
11 |
|
| 12 |
|
module InstanceMethods
|
|
12 |
module InstanceMethods
|
|
13 |
# Renders a tree of projects that the current user does not belong
|
|
14 |
# to, or of all projects if the current user is not logged in. The
|
|
15 |
# given collection may be a subset of the whole project tree
|
|
16 |
# (eg. some intermediate nodes are private and can not be seen). We
|
|
17 |
# are potentially interested in various things: the project name,
|
|
18 |
# description, manager(s), creation date, last activity date,
|
|
19 |
# general activity level, whether there is anything actually hosted
|
|
20 |
# here for the project, etc.
|
|
21 |
def render_project_table_with_filtering(projects, question)
|
|
22 |
custom_fields = ""
|
|
23 |
s = ""
|
|
24 |
if projects.any?
|
|
25 |
tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields)
|
|
26 |
|
|
27 |
s << "<div class='autoscroll'>"
|
|
28 |
s << "<table class='list projects'>"
|
|
29 |
s << "<thead><tr>"
|
|
30 |
|
|
31 |
s << sort_header_tag('name', :caption => l("field_name"))
|
|
32 |
s << "<th class='managers'>" << l("label_managers") << "</th>"
|
|
33 |
s << "<th class='tags'>" << l("tags") << "</th>"
|
|
34 |
s << sort_header_tag('created_on', :default_order => 'desc')
|
|
35 |
s << sort_header_tag('updated_on', :default_order => 'desc')
|
|
36 |
|
|
37 |
s << "</tr></thead><tbody>"
|
|
38 |
|
|
39 |
original_project = @project
|
|
40 |
|
|
41 |
projects.each do |project|
|
|
42 |
s << render_project_in_table_with_filtering(project, cycle('odd', 'even'), 0, tokens)
|
|
43 |
end
|
|
44 |
|
|
45 |
s << "</table>"
|
|
46 |
else
|
|
47 |
s << "\n"
|
|
48 |
end
|
|
49 |
@project = original_project
|
|
50 |
|
|
51 |
s
|
|
52 |
end
|
|
53 |
|
|
54 |
def render_project_in_table_with_filtering(project, oddeven, level, tokens)
|
|
55 |
# set the project environment to please macros.
|
|
56 |
@project = project
|
|
57 |
|
|
58 |
classes = (level == 0 ? 'root' : 'child')
|
|
59 |
|
|
60 |
s = ""
|
|
61 |
|
|
62 |
s << "<tr class='#{oddeven} #{classes} level#{level}'>"
|
|
63 |
s << "<td class='firstcol' align=top><div class='name hosted_here"
|
|
64 |
s << " no_description" if project.description.blank?
|
|
65 |
s << "'>" << link_to( highlight_tokens(project.name, tokens), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
|
66 |
s << "</div>"
|
|
67 |
s << render_project_short_description(project)
|
|
68 |
s << "<td class='managers' align=top>"
|
|
69 |
|
|
70 |
u = project.users_by_role
|
|
71 |
if u
|
|
72 |
u.keys.each do |r|
|
|
73 |
if r.allowed_to?(:edit_project)
|
|
74 |
mgrs = []
|
|
75 |
u[r].sort.each do |m|
|
|
76 |
mgrs << link_to_user(m)
|
|
77 |
end
|
|
78 |
if mgrs.size < 3
|
|
79 |
s << '<nobr>' << mgrs.join(', ') << '</nobr>'
|
|
80 |
else
|
|
81 |
s << mgrs.join(', ')
|
|
82 |
end
|
|
83 |
end
|
|
84 |
end
|
|
85 |
end
|
|
86 |
|
|
87 |
s << "</td>"
|
|
88 |
|
|
89 |
# taglist
|
|
90 |
s << "<td class='tags' align=top>" << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ') << "</td>"
|
|
91 |
s << "<td class='created_on' align=top>" << format_date(project.created_on) << "</td>"
|
|
92 |
s << "<td class='updated_on' align=top>" << format_date(project.updated_on) << "</td>"
|
|
93 |
|
|
94 |
s << "</tr>"
|
|
95 |
|
|
96 |
project.children.each do |child|
|
|
97 |
if child.is_public? or User.current.member_of?(child)
|
|
98 |
s << render_project_in_table_with_filtering(child, oddeven, level + 1, tokens)
|
|
99 |
end
|
|
100 |
end
|
|
101 |
|
|
102 |
s
|
|
103 |
end
|
|
104 |
|
|
105 |
|
|
106 |
|
| 13 |
107 |
# Renders a tree of projects as a nested set of unordered lists
|
| 14 |
108 |
# The given collection may be a subset of the whole project tree
|
| 15 |
109 |
# (eg. some intermediate nodes are private and can not be seen)
|