##// END OF EJS Templates
Adds a helper for displaying a link to add a subtask (#12113)....
Jean-Philippe Lang -
r10450:b8fbb41d5f63
parent child
Show More
@@ -1,398 +1,403
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2012 Jean-Philippe Lang
4 # Copyright (C) 2006-2012 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module IssuesHelper
20 module IssuesHelper
21 include ApplicationHelper
21 include ApplicationHelper
22
22
23 def issue_list(issues, &block)
23 def issue_list(issues, &block)
24 ancestors = []
24 ancestors = []
25 issues.each do |issue|
25 issues.each do |issue|
26 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
26 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
27 ancestors.pop
27 ancestors.pop
28 end
28 end
29 yield issue, ancestors.size
29 yield issue, ancestors.size
30 ancestors << issue unless issue.leaf?
30 ancestors << issue unless issue.leaf?
31 end
31 end
32 end
32 end
33
33
34 # Renders a HTML/CSS tooltip
34 # Renders a HTML/CSS tooltip
35 #
35 #
36 # To use, a trigger div is needed. This is a div with the class of "tooltip"
36 # To use, a trigger div is needed. This is a div with the class of "tooltip"
37 # that contains this method wrapped in a span with the class of "tip"
37 # that contains this method wrapped in a span with the class of "tip"
38 #
38 #
39 # <div class="tooltip"><%= link_to_issue(issue) %>
39 # <div class="tooltip"><%= link_to_issue(issue) %>
40 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
40 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
41 # </div>
41 # </div>
42 #
42 #
43 def render_issue_tooltip(issue)
43 def render_issue_tooltip(issue)
44 @cached_label_status ||= l(:field_status)
44 @cached_label_status ||= l(:field_status)
45 @cached_label_start_date ||= l(:field_start_date)
45 @cached_label_start_date ||= l(:field_start_date)
46 @cached_label_due_date ||= l(:field_due_date)
46 @cached_label_due_date ||= l(:field_due_date)
47 @cached_label_assigned_to ||= l(:field_assigned_to)
47 @cached_label_assigned_to ||= l(:field_assigned_to)
48 @cached_label_priority ||= l(:field_priority)
48 @cached_label_priority ||= l(:field_priority)
49 @cached_label_project ||= l(:field_project)
49 @cached_label_project ||= l(:field_project)
50
50
51 link_to_issue(issue) + "<br /><br />".html_safe +
51 link_to_issue(issue) + "<br /><br />".html_safe +
52 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
52 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
53 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
53 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
54 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
54 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
55 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
55 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
56 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
56 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
57 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
57 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
58 end
58 end
59
59
60 def issue_heading(issue)
60 def issue_heading(issue)
61 h("#{issue.tracker} ##{issue.id}")
61 h("#{issue.tracker} ##{issue.id}")
62 end
62 end
63
63
64 def render_issue_subject_with_tree(issue)
64 def render_issue_subject_with_tree(issue)
65 s = ''
65 s = ''
66 ancestors = issue.root? ? [] : issue.ancestors.visible.all
66 ancestors = issue.root? ? [] : issue.ancestors.visible.all
67 ancestors.each do |ancestor|
67 ancestors.each do |ancestor|
68 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
68 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
69 end
69 end
70 s << '<div>'
70 s << '<div>'
71 subject = h(issue.subject)
71 subject = h(issue.subject)
72 if issue.is_private?
72 if issue.is_private?
73 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
73 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
74 end
74 end
75 s << content_tag('h3', subject)
75 s << content_tag('h3', subject)
76 s << '</div>' * (ancestors.size + 1)
76 s << '</div>' * (ancestors.size + 1)
77 s.html_safe
77 s.html_safe
78 end
78 end
79
79
80 def render_descendants_tree(issue)
80 def render_descendants_tree(issue)
81 s = '<form><table class="list issues">'
81 s = '<form><table class="list issues">'
82 issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
82 issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
83 css = "issue issue-#{child.id} hascontextmenu"
83 css = "issue issue-#{child.id} hascontextmenu"
84 css << " idnt idnt-#{level}" if level > 0
84 css << " idnt idnt-#{level}" if level > 0
85 s << content_tag('tr',
85 s << content_tag('tr',
86 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
86 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
87 content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') +
87 content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') +
88 content_tag('td', h(child.status)) +
88 content_tag('td', h(child.status)) +
89 content_tag('td', link_to_user(child.assigned_to)) +
89 content_tag('td', link_to_user(child.assigned_to)) +
90 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
90 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
91 :class => css)
91 :class => css)
92 end
92 end
93 s << '</table></form>'
93 s << '</table></form>'
94 s.html_safe
94 s.html_safe
95 end
95 end
96
96
97 # Returns a link for adding a new subtask to the given issue
98 def link_to_new_subtask(issue)
99 link_to(l(:button_add), {:controller => 'issues', :action => 'new', :project_id => issue.project, :issue => {:parent_issue_id => issue}})
100 end
101
97 class IssueFieldsRows
102 class IssueFieldsRows
98 include ActionView::Helpers::TagHelper
103 include ActionView::Helpers::TagHelper
99
104
100 def initialize
105 def initialize
101 @left = []
106 @left = []
102 @right = []
107 @right = []
103 end
108 end
104
109
105 def left(*args)
110 def left(*args)
106 args.any? ? @left << cells(*args) : @left
111 args.any? ? @left << cells(*args) : @left
107 end
112 end
108
113
109 def right(*args)
114 def right(*args)
110 args.any? ? @right << cells(*args) : @right
115 args.any? ? @right << cells(*args) : @right
111 end
116 end
112
117
113 def size
118 def size
114 @left.size > @right.size ? @left.size : @right.size
119 @left.size > @right.size ? @left.size : @right.size
115 end
120 end
116
121
117 def to_html
122 def to_html
118 html = ''.html_safe
123 html = ''.html_safe
119 blank = content_tag('th', '') + content_tag('td', '')
124 blank = content_tag('th', '') + content_tag('td', '')
120 size.times do |i|
125 size.times do |i|
121 left = @left[i] || blank
126 left = @left[i] || blank
122 right = @right[i] || blank
127 right = @right[i] || blank
123 html << content_tag('tr', left + right)
128 html << content_tag('tr', left + right)
124 end
129 end
125 html
130 html
126 end
131 end
127
132
128 def cells(label, text, options={})
133 def cells(label, text, options={})
129 content_tag('th', "#{label}:", options) + content_tag('td', text, options)
134 content_tag('th', "#{label}:", options) + content_tag('td', text, options)
130 end
135 end
131 end
136 end
132
137
133 def issue_fields_rows
138 def issue_fields_rows
134 r = IssueFieldsRows.new
139 r = IssueFieldsRows.new
135 yield r
140 yield r
136 r.to_html
141 r.to_html
137 end
142 end
138
143
139 def render_custom_fields_rows(issue)
144 def render_custom_fields_rows(issue)
140 return if issue.custom_field_values.empty?
145 return if issue.custom_field_values.empty?
141 ordered_values = []
146 ordered_values = []
142 half = (issue.custom_field_values.size / 2.0).ceil
147 half = (issue.custom_field_values.size / 2.0).ceil
143 half.times do |i|
148 half.times do |i|
144 ordered_values << issue.custom_field_values[i]
149 ordered_values << issue.custom_field_values[i]
145 ordered_values << issue.custom_field_values[i + half]
150 ordered_values << issue.custom_field_values[i + half]
146 end
151 end
147 s = "<tr>\n"
152 s = "<tr>\n"
148 n = 0
153 n = 0
149 ordered_values.compact.each do |value|
154 ordered_values.compact.each do |value|
150 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
155 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
151 s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
156 s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
152 n += 1
157 n += 1
153 end
158 end
154 s << "</tr>\n"
159 s << "</tr>\n"
155 s.html_safe
160 s.html_safe
156 end
161 end
157
162
158 def issues_destroy_confirmation_message(issues)
163 def issues_destroy_confirmation_message(issues)
159 issues = [issues] unless issues.is_a?(Array)
164 issues = [issues] unless issues.is_a?(Array)
160 message = l(:text_issues_destroy_confirmation)
165 message = l(:text_issues_destroy_confirmation)
161 descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
166 descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
162 if descendant_count > 0
167 if descendant_count > 0
163 issues.each do |issue|
168 issues.each do |issue|
164 next if issue.root?
169 next if issue.root?
165 issues.each do |other_issue|
170 issues.each do |other_issue|
166 descendant_count -= 1 if issue.is_descendant_of?(other_issue)
171 descendant_count -= 1 if issue.is_descendant_of?(other_issue)
167 end
172 end
168 end
173 end
169 if descendant_count > 0
174 if descendant_count > 0
170 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
175 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
171 end
176 end
172 end
177 end
173 message
178 message
174 end
179 end
175
180
176 def sidebar_queries
181 def sidebar_queries
177 unless @sidebar_queries
182 unless @sidebar_queries
178 @sidebar_queries = Query.visible.all(
183 @sidebar_queries = Query.visible.all(
179 :order => "#{Query.table_name}.name ASC",
184 :order => "#{Query.table_name}.name ASC",
180 # Project specific queries and global queries
185 # Project specific queries and global queries
181 :conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
186 :conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
182 )
187 )
183 end
188 end
184 @sidebar_queries
189 @sidebar_queries
185 end
190 end
186
191
187 def query_links(title, queries)
192 def query_links(title, queries)
188 # links to #index on issues/show
193 # links to #index on issues/show
189 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
194 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
190
195
191 content_tag('h3', h(title)) +
196 content_tag('h3', h(title)) +
192 queries.collect {|query|
197 queries.collect {|query|
193 css = 'query'
198 css = 'query'
194 css << ' selected' if query == @query
199 css << ' selected' if query == @query
195 link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
200 link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
196 }.join('<br />').html_safe
201 }.join('<br />').html_safe
197 end
202 end
198
203
199 def render_sidebar_queries
204 def render_sidebar_queries
200 out = ''.html_safe
205 out = ''.html_safe
201 queries = sidebar_queries.select {|q| !q.is_public?}
206 queries = sidebar_queries.select {|q| !q.is_public?}
202 out << query_links(l(:label_my_queries), queries) if queries.any?
207 out << query_links(l(:label_my_queries), queries) if queries.any?
203 queries = sidebar_queries.select {|q| q.is_public?}
208 queries = sidebar_queries.select {|q| q.is_public?}
204 out << query_links(l(:label_query_plural), queries) if queries.any?
209 out << query_links(l(:label_query_plural), queries) if queries.any?
205 out
210 out
206 end
211 end
207
212
208 # Returns the textual representation of a journal details
213 # Returns the textual representation of a journal details
209 # as an array of strings
214 # as an array of strings
210 def details_to_strings(details, no_html=false, options={})
215 def details_to_strings(details, no_html=false, options={})
211 options[:only_path] = (options[:only_path] == false ? false : true)
216 options[:only_path] = (options[:only_path] == false ? false : true)
212 strings = []
217 strings = []
213 values_by_field = {}
218 values_by_field = {}
214 details.each do |detail|
219 details.each do |detail|
215 if detail.property == 'cf'
220 if detail.property == 'cf'
216 field_id = detail.prop_key
221 field_id = detail.prop_key
217 field = CustomField.find_by_id(field_id)
222 field = CustomField.find_by_id(field_id)
218 if field && field.multiple?
223 if field && field.multiple?
219 values_by_field[field_id] ||= {:added => [], :deleted => []}
224 values_by_field[field_id] ||= {:added => [], :deleted => []}
220 if detail.old_value
225 if detail.old_value
221 values_by_field[field_id][:deleted] << detail.old_value
226 values_by_field[field_id][:deleted] << detail.old_value
222 end
227 end
223 if detail.value
228 if detail.value
224 values_by_field[field_id][:added] << detail.value
229 values_by_field[field_id][:added] << detail.value
225 end
230 end
226 next
231 next
227 end
232 end
228 end
233 end
229 strings << show_detail(detail, no_html, options)
234 strings << show_detail(detail, no_html, options)
230 end
235 end
231 values_by_field.each do |field_id, changes|
236 values_by_field.each do |field_id, changes|
232 detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
237 detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
233 if changes[:added].any?
238 if changes[:added].any?
234 detail.value = changes[:added]
239 detail.value = changes[:added]
235 strings << show_detail(detail, no_html, options)
240 strings << show_detail(detail, no_html, options)
236 elsif changes[:deleted].any?
241 elsif changes[:deleted].any?
237 detail.old_value = changes[:deleted]
242 detail.old_value = changes[:deleted]
238 strings << show_detail(detail, no_html, options)
243 strings << show_detail(detail, no_html, options)
239 end
244 end
240 end
245 end
241 strings
246 strings
242 end
247 end
243
248
244 # Returns the textual representation of a single journal detail
249 # Returns the textual representation of a single journal detail
245 def show_detail(detail, no_html=false, options={})
250 def show_detail(detail, no_html=false, options={})
246 multiple = false
251 multiple = false
247 case detail.property
252 case detail.property
248 when 'attr'
253 when 'attr'
249 field = detail.prop_key.to_s.gsub(/\_id$/, "")
254 field = detail.prop_key.to_s.gsub(/\_id$/, "")
250 label = l(("field_" + field).to_sym)
255 label = l(("field_" + field).to_sym)
251 case detail.prop_key
256 case detail.prop_key
252 when 'due_date', 'start_date'
257 when 'due_date', 'start_date'
253 value = format_date(detail.value.to_date) if detail.value
258 value = format_date(detail.value.to_date) if detail.value
254 old_value = format_date(detail.old_value.to_date) if detail.old_value
259 old_value = format_date(detail.old_value.to_date) if detail.old_value
255
260
256 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
261 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
257 'priority_id', 'category_id', 'fixed_version_id'
262 'priority_id', 'category_id', 'fixed_version_id'
258 value = find_name_by_reflection(field, detail.value)
263 value = find_name_by_reflection(field, detail.value)
259 old_value = find_name_by_reflection(field, detail.old_value)
264 old_value = find_name_by_reflection(field, detail.old_value)
260
265
261 when 'estimated_hours'
266 when 'estimated_hours'
262 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
267 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
263 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
268 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
264
269
265 when 'parent_id'
270 when 'parent_id'
266 label = l(:field_parent_issue)
271 label = l(:field_parent_issue)
267 value = "##{detail.value}" unless detail.value.blank?
272 value = "##{detail.value}" unless detail.value.blank?
268 old_value = "##{detail.old_value}" unless detail.old_value.blank?
273 old_value = "##{detail.old_value}" unless detail.old_value.blank?
269
274
270 when 'is_private'
275 when 'is_private'
271 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
276 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
272 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
277 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
273 end
278 end
274 when 'cf'
279 when 'cf'
275 custom_field = CustomField.find_by_id(detail.prop_key)
280 custom_field = CustomField.find_by_id(detail.prop_key)
276 if custom_field
281 if custom_field
277 multiple = custom_field.multiple?
282 multiple = custom_field.multiple?
278 label = custom_field.name
283 label = custom_field.name
279 value = format_value(detail.value, custom_field.field_format) if detail.value
284 value = format_value(detail.value, custom_field.field_format) if detail.value
280 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
285 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
281 end
286 end
282 when 'attachment'
287 when 'attachment'
283 label = l(:label_attachment)
288 label = l(:label_attachment)
284 end
289 end
285 call_hook(:helper_issues_show_detail_after_setting,
290 call_hook(:helper_issues_show_detail_after_setting,
286 {:detail => detail, :label => label, :value => value, :old_value => old_value })
291 {:detail => detail, :label => label, :value => value, :old_value => old_value })
287
292
288 label ||= detail.prop_key
293 label ||= detail.prop_key
289 value ||= detail.value
294 value ||= detail.value
290 old_value ||= detail.old_value
295 old_value ||= detail.old_value
291
296
292 unless no_html
297 unless no_html
293 label = content_tag('strong', label)
298 label = content_tag('strong', label)
294 old_value = content_tag("i", h(old_value)) if detail.old_value
299 old_value = content_tag("i", h(old_value)) if detail.old_value
295 old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
300 old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
296 if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
301 if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
297 # Link to the attachment if it has not been removed
302 # Link to the attachment if it has not been removed
298 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
303 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
299 if options[:only_path] != false && atta.is_text?
304 if options[:only_path] != false && atta.is_text?
300 value += link_to(
305 value += link_to(
301 image_tag('magnifier.png'),
306 image_tag('magnifier.png'),
302 :controller => 'attachments', :action => 'show',
307 :controller => 'attachments', :action => 'show',
303 :id => atta, :filename => atta.filename
308 :id => atta, :filename => atta.filename
304 )
309 )
305 end
310 end
306 else
311 else
307 value = content_tag("i", h(value)) if value
312 value = content_tag("i", h(value)) if value
308 end
313 end
309 end
314 end
310
315
311 if detail.property == 'attr' && detail.prop_key == 'description'
316 if detail.property == 'attr' && detail.prop_key == 'description'
312 s = l(:text_journal_changed_no_detail, :label => label)
317 s = l(:text_journal_changed_no_detail, :label => label)
313 unless no_html
318 unless no_html
314 diff_link = link_to 'diff',
319 diff_link = link_to 'diff',
315 {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
320 {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
316 :detail_id => detail.id, :only_path => options[:only_path]},
321 :detail_id => detail.id, :only_path => options[:only_path]},
317 :title => l(:label_view_diff)
322 :title => l(:label_view_diff)
318 s << " (#{ diff_link })"
323 s << " (#{ diff_link })"
319 end
324 end
320 s.html_safe
325 s.html_safe
321 elsif detail.value.present?
326 elsif detail.value.present?
322 case detail.property
327 case detail.property
323 when 'attr', 'cf'
328 when 'attr', 'cf'
324 if detail.old_value.present?
329 if detail.old_value.present?
325 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
330 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
326 elsif multiple
331 elsif multiple
327 l(:text_journal_added, :label => label, :value => value).html_safe
332 l(:text_journal_added, :label => label, :value => value).html_safe
328 else
333 else
329 l(:text_journal_set_to, :label => label, :value => value).html_safe
334 l(:text_journal_set_to, :label => label, :value => value).html_safe
330 end
335 end
331 when 'attachment'
336 when 'attachment'
332 l(:text_journal_added, :label => label, :value => value).html_safe
337 l(:text_journal_added, :label => label, :value => value).html_safe
333 end
338 end
334 else
339 else
335 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
340 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
336 end
341 end
337 end
342 end
338
343
339 # Find the name of an associated record stored in the field attribute
344 # Find the name of an associated record stored in the field attribute
340 def find_name_by_reflection(field, id)
345 def find_name_by_reflection(field, id)
341 association = Issue.reflect_on_association(field.to_sym)
346 association = Issue.reflect_on_association(field.to_sym)
342 if association
347 if association
343 record = association.class_name.constantize.find_by_id(id)
348 record = association.class_name.constantize.find_by_id(id)
344 return record.name if record
349 return record.name if record
345 end
350 end
346 end
351 end
347
352
348 # Renders issue children recursively
353 # Renders issue children recursively
349 def render_api_issue_children(issue, api)
354 def render_api_issue_children(issue, api)
350 return if issue.leaf?
355 return if issue.leaf?
351 api.array :children do
356 api.array :children do
352 issue.children.each do |child|
357 issue.children.each do |child|
353 api.issue(:id => child.id) do
358 api.issue(:id => child.id) do
354 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
359 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
355 api.subject child.subject
360 api.subject child.subject
356 render_api_issue_children(child, api)
361 render_api_issue_children(child, api)
357 end
362 end
358 end
363 end
359 end
364 end
360 end
365 end
361
366
362 def issues_to_csv(issues, project, query, options={})
367 def issues_to_csv(issues, project, query, options={})
363 decimal_separator = l(:general_csv_decimal_separator)
368 decimal_separator = l(:general_csv_decimal_separator)
364 encoding = l(:general_csv_encoding)
369 encoding = l(:general_csv_encoding)
365 columns = (options[:columns] == 'all' ? query.available_columns : query.columns)
370 columns = (options[:columns] == 'all' ? query.available_columns : query.columns)
366
371
367 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
372 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
368 # csv header fields
373 # csv header fields
369 csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
374 csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
370 (options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])
375 (options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])
371
376
372 # csv lines
377 # csv lines
373 issues.each do |issue|
378 issues.each do |issue|
374 col_values = columns.collect do |column|
379 col_values = columns.collect do |column|
375 s = if column.is_a?(QueryCustomFieldColumn)
380 s = if column.is_a?(QueryCustomFieldColumn)
376 cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
381 cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
377 show_value(cv)
382 show_value(cv)
378 else
383 else
379 value = column.value(issue)
384 value = column.value(issue)
380 if value.is_a?(Date)
385 if value.is_a?(Date)
381 format_date(value)
386 format_date(value)
382 elsif value.is_a?(Time)
387 elsif value.is_a?(Time)
383 format_time(value)
388 format_time(value)
384 elsif value.is_a?(Float)
389 elsif value.is_a?(Float)
385 ("%.2f" % value).gsub('.', decimal_separator)
390 ("%.2f" % value).gsub('.', decimal_separator)
386 else
391 else
387 value
392 value
388 end
393 end
389 end
394 end
390 s.to_s
395 s.to_s
391 end
396 end
392 csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } +
397 csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } +
393 (options[:description] ? [Redmine::CodesetUtil.from_utf8(issue.description, encoding)] : [])
398 (options[:description] ? [Redmine::CodesetUtil.from_utf8(issue.description, encoding)] : [])
394 end
399 end
395 end
400 end
396 export
401 export
397 end
402 end
398 end
403 end
@@ -1,160 +1,160
1 <%= render :partial => 'action_menu' %>
1 <%= render :partial => 'action_menu' %>
2
2
3 <h2><%= issue_heading(@issue) %></h2>
3 <h2><%= issue_heading(@issue) %></h2>
4
4
5 <div class="<%= @issue.css_classes %> details">
5 <div class="<%= @issue.css_classes %> details">
6 <% if @prev_issue_id || @next_issue_id %>
6 <% if @prev_issue_id || @next_issue_id %>
7 <div class="next-prev-links contextual">
7 <div class="next-prev-links contextual">
8 <%= link_to_if @prev_issue_id,
8 <%= link_to_if @prev_issue_id,
9 "\xc2\xab #{l(:label_previous)}",
9 "\xc2\xab #{l(:label_previous)}",
10 (@prev_issue_id ? issue_path(@prev_issue_id) : nil),
10 (@prev_issue_id ? issue_path(@prev_issue_id) : nil),
11 :title => "##{@prev_issue_id}" %> |
11 :title => "##{@prev_issue_id}" %> |
12 <% if @issue_position && @issue_count %>
12 <% if @issue_position && @issue_count %>
13 <span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
13 <span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
14 <% end %>
14 <% end %>
15 <%= link_to_if @next_issue_id,
15 <%= link_to_if @next_issue_id,
16 "#{l(:label_next)} \xc2\xbb",
16 "#{l(:label_next)} \xc2\xbb",
17 (@next_issue_id ? issue_path(@next_issue_id) : nil),
17 (@next_issue_id ? issue_path(@next_issue_id) : nil),
18 :title => "##{@next_issue_id}" %>
18 :title => "##{@next_issue_id}" %>
19 </div>
19 </div>
20 <% end %>
20 <% end %>
21
21
22 <%= avatar(@issue.author, :size => "50") %>
22 <%= avatar(@issue.author, :size => "50") %>
23
23
24 <div class="subject">
24 <div class="subject">
25 <%= render_issue_subject_with_tree(@issue) %>
25 <%= render_issue_subject_with_tree(@issue) %>
26 </div>
26 </div>
27 <p class="author">
27 <p class="author">
28 <%= authoring @issue.created_on, @issue.author %>.
28 <%= authoring @issue.created_on, @issue.author %>.
29 <% if @issue.created_on != @issue.updated_on %>
29 <% if @issue.created_on != @issue.updated_on %>
30 <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
30 <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
31 <% end %>
31 <% end %>
32 </p>
32 </p>
33
33
34 <table class="attributes">
34 <table class="attributes">
35 <%= issue_fields_rows do |rows|
35 <%= issue_fields_rows do |rows|
36 rows.left l(:field_status), h(@issue.status.name), :class => 'status'
36 rows.left l(:field_status), h(@issue.status.name), :class => 'status'
37 rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority'
37 rows.left l(:field_priority), h(@issue.priority.name), :class => 'priority'
38
38
39 unless @issue.disabled_core_fields.include?('assigned_to_id')
39 unless @issue.disabled_core_fields.include?('assigned_to_id')
40 rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to'
40 rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to'
41 end
41 end
42 unless @issue.disabled_core_fields.include?('category_id')
42 unless @issue.disabled_core_fields.include?('category_id')
43 rows.left l(:field_category), h(@issue.category ? @issue.category.name : "-"), :class => 'category'
43 rows.left l(:field_category), h(@issue.category ? @issue.category.name : "-"), :class => 'category'
44 end
44 end
45 unless @issue.disabled_core_fields.include?('fixed_version_id')
45 unless @issue.disabled_core_fields.include?('fixed_version_id')
46 rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
46 rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
47 end
47 end
48
48
49 unless @issue.disabled_core_fields.include?('start_date')
49 unless @issue.disabled_core_fields.include?('start_date')
50 rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
50 rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
51 end
51 end
52 unless @issue.disabled_core_fields.include?('due_date')
52 unless @issue.disabled_core_fields.include?('due_date')
53 rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
53 rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
54 end
54 end
55 unless @issue.disabled_core_fields.include?('done_ratio')
55 unless @issue.disabled_core_fields.include?('done_ratio')
56 rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress'
56 rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress'
57 end
57 end
58 unless @issue.disabled_core_fields.include?('estimated_hours')
58 unless @issue.disabled_core_fields.include?('estimated_hours')
59 unless @issue.estimated_hours.nil?
59 unless @issue.estimated_hours.nil?
60 rows.right l(:field_estimated_hours), l_hours(@issue.estimated_hours), :class => 'estimated-hours'
60 rows.right l(:field_estimated_hours), l_hours(@issue.estimated_hours), :class => 'estimated-hours'
61 end
61 end
62 end
62 end
63 if User.current.allowed_to?(:view_time_entries, @project)
63 if User.current.allowed_to?(:view_time_entries, @project)
64 rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? (link_to l_hours(@issue.total_spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-"), :class => 'spent-time'
64 rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? (link_to l_hours(@issue.total_spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-"), :class => 'spent-time'
65 end
65 end
66 end %>
66 end %>
67 <%= render_custom_fields_rows(@issue) %>
67 <%= render_custom_fields_rows(@issue) %>
68 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
68 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
69 </table>
69 </table>
70
70
71 <% if @issue.description? || @issue.attachments.any? -%>
71 <% if @issue.description? || @issue.attachments.any? -%>
72 <hr />
72 <hr />
73 <% if @issue.description? %>
73 <% if @issue.description? %>
74 <div class="contextual">
74 <div class="contextual">
75 <%= link_to l(:button_quote),
75 <%= link_to l(:button_quote),
76 {:controller => 'journals', :action => 'new', :id => @issue},
76 {:controller => 'journals', :action => 'new', :id => @issue},
77 :remote => true,
77 :remote => true,
78 :method => 'post',
78 :method => 'post',
79 :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
79 :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
80 </div>
80 </div>
81
81
82 <p><strong><%=l(:field_description)%></strong></p>
82 <p><strong><%=l(:field_description)%></strong></p>
83 <div class="wiki">
83 <div class="wiki">
84 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
84 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
85 </div>
85 </div>
86 <% end %>
86 <% end %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
88 <% end -%>
88 <% end -%>
89
89
90 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
90 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
91
91
92 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
92 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
93 <hr />
93 <hr />
94 <div id="issue_tree">
94 <div id="issue_tree">
95 <div class="contextual">
95 <div class="contextual">
96 <%= link_to(l(:button_add), {:controller => 'issues', :action => 'new', :project_id => @project, :issue => {:parent_issue_id => @issue}}) if User.current.allowed_to?(:manage_subtasks, @project) %>
96 <%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
97 </div>
97 </div>
98 <p><strong><%=l(:label_subtask_plural)%></strong></p>
98 <p><strong><%=l(:label_subtask_plural)%></strong></p>
99 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
99 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
100 </div>
100 </div>
101 <% end %>
101 <% end %>
102
102
103 <% if @relations.present? || User.current.allowed_to?(:manage_issue_relations, @project) %>
103 <% if @relations.present? || User.current.allowed_to?(:manage_issue_relations, @project) %>
104 <hr />
104 <hr />
105 <div id="relations">
105 <div id="relations">
106 <%= render :partial => 'relations' %>
106 <%= render :partial => 'relations' %>
107 </div>
107 </div>
108 <% end %>
108 <% end %>
109
109
110 </div>
110 </div>
111
111
112 <% if @changesets.present? %>
112 <% if @changesets.present? %>
113 <div id="issue-changesets">
113 <div id="issue-changesets">
114 <h3><%=l(:label_associated_revisions)%></h3>
114 <h3><%=l(:label_associated_revisions)%></h3>
115 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
115 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
116 </div>
116 </div>
117 <% end %>
117 <% end %>
118
118
119 <% if @journals.present? %>
119 <% if @journals.present? %>
120 <div id="history">
120 <div id="history">
121 <h3><%=l(:label_history)%></h3>
121 <h3><%=l(:label_history)%></h3>
122 <%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
122 <%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
123 </div>
123 </div>
124 <% end %>
124 <% end %>
125
125
126
126
127 <div style="clear: both;"></div>
127 <div style="clear: both;"></div>
128 <%= render :partial => 'action_menu' %>
128 <%= render :partial => 'action_menu' %>
129
129
130 <div style="clear: both;"></div>
130 <div style="clear: both;"></div>
131 <% if authorize_for('issues', 'edit') %>
131 <% if authorize_for('issues', 'edit') %>
132 <div id="update" style="display:none;">
132 <div id="update" style="display:none;">
133 <h3><%= l(:button_update) %></h3>
133 <h3><%= l(:button_update) %></h3>
134 <%= render :partial => 'edit' %>
134 <%= render :partial => 'edit' %>
135 </div>
135 </div>
136 <% end %>
136 <% end %>
137
137
138 <% other_formats_links do |f| %>
138 <% other_formats_links do |f| %>
139 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
139 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
140 <%= f.link_to 'PDF' %>
140 <%= f.link_to 'PDF' %>
141 <% end %>
141 <% end %>
142
142
143 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
143 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
144
144
145 <% content_for :sidebar do %>
145 <% content_for :sidebar do %>
146 <%= render :partial => 'issues/sidebar' %>
146 <%= render :partial => 'issues/sidebar' %>
147
147
148 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
148 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
149 (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
149 (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
150 <div id="watchers">
150 <div id="watchers">
151 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
151 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
152 </div>
152 </div>
153 <% end %>
153 <% end %>
154 <% end %>
154 <% end %>
155
155
156 <% content_for :header_tags do %>
156 <% content_for :header_tags do %>
157 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
157 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
158 <% end %>
158 <% end %>
159
159
160 <%= context_menu issues_context_menu_path %>
160 <%= context_menu issues_context_menu_path %>
General Comments 0
You need to be logged in to leave comments. Login now