##// END OF EJS Templates
Add Issue Status to the tooltip. #6169...
Eric Davis -
r3838:782a5f121881
parent child
Show More
@@ -1,262 +1,264
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module IssuesHelper
19 19 include ApplicationHelper
20 20
21 21 def issue_list(issues, &block)
22 22 ancestors = []
23 23 issues.each do |issue|
24 24 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
25 25 ancestors.pop
26 26 end
27 27 yield issue, ancestors.size
28 28 ancestors << issue unless issue.leaf?
29 29 end
30 30 end
31 31
32 32 def render_issue_tooltip(issue)
33 @cached_label_status ||= l(:field_status)
33 34 @cached_label_start_date ||= l(:field_start_date)
34 35 @cached_label_due_date ||= l(:field_due_date)
35 36 @cached_label_assigned_to ||= l(:field_assigned_to)
36 37 @cached_label_priority ||= l(:field_priority)
37 38
38 39 link_to_issue(issue) + "<br /><br />" +
40 "<strong>#{@cached_label_status}</strong>: #{issue.status.name}<br />" +
39 41 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
40 42 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
41 43 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
42 44 "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
43 45 end
44 46
45 47 def render_issue_subject_with_tree(issue)
46 48 s = ''
47 49 issue.ancestors.each do |ancestor|
48 50 s << '<div>' + content_tag('p', link_to_issue(ancestor))
49 51 end
50 52 s << '<div>' + content_tag('h3', h(issue.subject))
51 53 s << '</div>' * (issue.ancestors.size + 1)
52 54 s
53 55 end
54 56
55 57 def render_descendants_tree(issue)
56 58 s = '<form><table class="list issues">'
57 59 issue_list(issue.descendants.sort_by(&:lft)) do |child, level|
58 60 s << content_tag('tr',
59 61 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
60 62 content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') +
61 63 content_tag('td', h(child.status)) +
62 64 content_tag('td', link_to_user(child.assigned_to)) +
63 65 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
64 66 :class => "issue issue-#{child.id} hascontextmenu #{level > 0 ? "idnt idnt-#{level}" : nil}")
65 67 end
66 68 s << '</form></table>'
67 69 s
68 70 end
69 71
70 72 def render_custom_fields_rows(issue)
71 73 return if issue.custom_field_values.empty?
72 74 ordered_values = []
73 75 half = (issue.custom_field_values.size / 2.0).ceil
74 76 half.times do |i|
75 77 ordered_values << issue.custom_field_values[i]
76 78 ordered_values << issue.custom_field_values[i + half]
77 79 end
78 80 s = "<tr>\n"
79 81 n = 0
80 82 ordered_values.compact.each do |value|
81 83 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
82 84 s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
83 85 n += 1
84 86 end
85 87 s << "</tr>\n"
86 88 s
87 89 end
88 90
89 91 def sidebar_queries
90 92 unless @sidebar_queries
91 93 # User can see public queries and his own queries
92 94 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
93 95 # Project specific queries and global queries
94 96 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
95 97 @sidebar_queries = Query.find(:all,
96 98 :select => 'id, name',
97 99 :order => "name ASC",
98 100 :conditions => visible.conditions)
99 101 end
100 102 @sidebar_queries
101 103 end
102 104
103 105 def show_detail(detail, no_html=false)
104 106 case detail.property
105 107 when 'attr'
106 108 field = detail.prop_key.to_s.gsub(/\_id$/, "")
107 109 label = l(("field_" + field).to_sym)
108 110 case
109 111 when ['due_date', 'start_date'].include?(detail.prop_key)
110 112 value = format_date(detail.value.to_date) if detail.value
111 113 old_value = format_date(detail.old_value.to_date) if detail.old_value
112 114
113 115 when ['project_id', 'status_id', 'tracker_id', 'assigned_to_id', 'priority_id', 'category_id', 'fixed_version_id'].include?(detail.prop_key)
114 116 value = find_name_by_reflection(field, detail.value)
115 117 old_value = find_name_by_reflection(field, detail.old_value)
116 118
117 119 when detail.prop_key == 'estimated_hours'
118 120 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
119 121 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
120 122
121 123 when detail.prop_key == 'parent_id'
122 124 label = l(:field_parent_issue)
123 125 value = "##{detail.value}" unless detail.value.blank?
124 126 old_value = "##{detail.old_value}" unless detail.old_value.blank?
125 127 end
126 128 when 'cf'
127 129 custom_field = CustomField.find_by_id(detail.prop_key)
128 130 if custom_field
129 131 label = custom_field.name
130 132 value = format_value(detail.value, custom_field.field_format) if detail.value
131 133 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
132 134 end
133 135 when 'attachment'
134 136 label = l(:label_attachment)
135 137 end
136 138 call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })
137 139
138 140 label ||= detail.prop_key
139 141 value ||= detail.value
140 142 old_value ||= detail.old_value
141 143
142 144 unless no_html
143 145 label = content_tag('strong', label)
144 146 old_value = content_tag("i", h(old_value)) if detail.old_value
145 147 old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
146 148 if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
147 149 # Link to the attachment if it has not been removed
148 150 value = link_to_attachment(a)
149 151 else
150 152 value = content_tag("i", h(value)) if value
151 153 end
152 154 end
153 155
154 156 if !detail.value.blank?
155 157 case detail.property
156 158 when 'attr', 'cf'
157 159 if !detail.old_value.blank?
158 160 l(:text_journal_changed, :label => label, :old => old_value, :new => value)
159 161 else
160 162 l(:text_journal_set_to, :label => label, :value => value)
161 163 end
162 164 when 'attachment'
163 165 l(:text_journal_added, :label => label, :value => value)
164 166 end
165 167 else
166 168 l(:text_journal_deleted, :label => label, :old => old_value)
167 169 end
168 170 end
169 171
170 172 # Find the name of an associated record stored in the field attribute
171 173 def find_name_by_reflection(field, id)
172 174 association = Issue.reflect_on_association(field.to_sym)
173 175 if association
174 176 record = association.class_name.constantize.find_by_id(id)
175 177 return record.name if record
176 178 end
177 179 end
178 180
179 181 def issues_to_csv(issues, project = nil)
180 182 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
181 183 decimal_separator = l(:general_csv_decimal_separator)
182 184 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
183 185 # csv header fields
184 186 headers = [ "#",
185 187 l(:field_status),
186 188 l(:field_project),
187 189 l(:field_tracker),
188 190 l(:field_priority),
189 191 l(:field_subject),
190 192 l(:field_assigned_to),
191 193 l(:field_category),
192 194 l(:field_fixed_version),
193 195 l(:field_author),
194 196 l(:field_start_date),
195 197 l(:field_due_date),
196 198 l(:field_done_ratio),
197 199 l(:field_estimated_hours),
198 200 l(:field_parent_issue),
199 201 l(:field_created_on),
200 202 l(:field_updated_on)
201 203 ]
202 204 # Export project custom fields if project is given
203 205 # otherwise export custom fields marked as "For all projects"
204 206 custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
205 207 custom_fields.each {|f| headers << f.name}
206 208 # Description in the last column
207 209 headers << l(:field_description)
208 210 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
209 211 # csv lines
210 212 issues.each do |issue|
211 213 fields = [issue.id,
212 214 issue.status.name,
213 215 issue.project.name,
214 216 issue.tracker.name,
215 217 issue.priority.name,
216 218 issue.subject,
217 219 issue.assigned_to,
218 220 issue.category,
219 221 issue.fixed_version,
220 222 issue.author.name,
221 223 format_date(issue.start_date),
222 224 format_date(issue.due_date),
223 225 issue.done_ratio,
224 226 issue.estimated_hours.to_s.gsub('.', decimal_separator),
225 227 issue.parent_id,
226 228 format_time(issue.created_on),
227 229 format_time(issue.updated_on)
228 230 ]
229 231 custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
230 232 fields << issue.description
231 233 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
232 234 end
233 235 end
234 236 export
235 237 end
236 238
237 239 def gantt_zoom_link(gantt, in_or_out)
238 240 img_attributes = {:style => 'height:1.4em; width:1.4em; margin-left: 3px;'} # em for accessibility
239 241
240 242 case in_or_out
241 243 when :in
242 244 if gantt.zoom < 4
243 245 link_to_remote(l(:text_zoom_in) + image_tag('zoom_in.png', img_attributes.merge(:alt => l(:text_zoom_in))),
244 246 {:url => gantt.params.merge(:zoom => (gantt.zoom+1)), :update => 'content'},
245 247 {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom+1)))})
246 248 else
247 249 l(:text_zoom_in) +
248 250 image_tag('zoom_in_g.png', img_attributes.merge(:alt => l(:text_zoom_in)))
249 251 end
250 252
251 253 when :out
252 254 if gantt.zoom > 1
253 255 link_to_remote(l(:text_zoom_out) + image_tag('zoom_out.png', img_attributes.merge(:alt => l(:text_zoom_out))),
254 256 {:url => gantt.params.merge(:zoom => (gantt.zoom-1)), :update => 'content'},
255 257 {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom-1)))})
256 258 else
257 259 l(:text_zoom_out) +
258 260 image_tag('zoom_out_g.png', img_attributes.merge(:alt => l(:text_zoom_out)))
259 261 end
260 262 end
261 263 end
262 264 end
General Comments 0
You need to be logged in to leave comments. Login now