##// END OF EJS Templates
Adds 'closed' css class to closed issues in the issue list (#2458)....
Jean-Philippe Lang -
r2248:c0f44db4f705
parent child
Show More
@@ -1,195 +1,196
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'csv'
18 require 'csv'
19
19
20 module IssuesHelper
20 module IssuesHelper
21 include ApplicationHelper
21 include ApplicationHelper
22
22
23 def render_issue_tooltip(issue)
23 def render_issue_tooltip(issue)
24 @cached_label_start_date ||= l(:field_start_date)
24 @cached_label_start_date ||= l(:field_start_date)
25 @cached_label_due_date ||= l(:field_due_date)
25 @cached_label_due_date ||= l(:field_due_date)
26 @cached_label_assigned_to ||= l(:field_assigned_to)
26 @cached_label_assigned_to ||= l(:field_assigned_to)
27 @cached_label_priority ||= l(:field_priority)
27 @cached_label_priority ||= l(:field_priority)
28
28
29 link_to_issue(issue) + ": #{h(issue.subject)}<br /><br />" +
29 link_to_issue(issue) + ": #{h(issue.subject)}<br /><br />" +
30 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
30 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
31 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
31 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
32 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
32 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
33 "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
33 "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
34 end
34 end
35
35
36 # Returns a string of css classes that apply to the given issue
36 # Returns a string of css classes that apply to the given issue
37 def css_issue_classes(issue)
37 def css_issue_classes(issue)
38 s = "issue status-#{issue.status.position} priority-#{issue.priority.position}"
38 s = "issue status-#{issue.status.position} priority-#{issue.priority.position}"
39 s << ' closed' if issue.closed?
39 s << ' overdue' if issue.overdue?
40 s << ' overdue' if issue.overdue?
40 s
41 s
41 end
42 end
42
43
43 def sidebar_queries
44 def sidebar_queries
44 unless @sidebar_queries
45 unless @sidebar_queries
45 # User can see public queries and his own queries
46 # User can see public queries and his own queries
46 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
47 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
47 # Project specific queries and global queries
48 # Project specific queries and global queries
48 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
49 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
49 @sidebar_queries = Query.find(:all,
50 @sidebar_queries = Query.find(:all,
50 :order => "name ASC",
51 :order => "name ASC",
51 :conditions => visible.conditions)
52 :conditions => visible.conditions)
52 end
53 end
53 @sidebar_queries
54 @sidebar_queries
54 end
55 end
55
56
56 def show_detail(detail, no_html=false)
57 def show_detail(detail, no_html=false)
57 case detail.property
58 case detail.property
58 when 'attr'
59 when 'attr'
59 label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
60 label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
60 case detail.prop_key
61 case detail.prop_key
61 when 'due_date', 'start_date'
62 when 'due_date', 'start_date'
62 value = format_date(detail.value.to_date) if detail.value
63 value = format_date(detail.value.to_date) if detail.value
63 old_value = format_date(detail.old_value.to_date) if detail.old_value
64 old_value = format_date(detail.old_value.to_date) if detail.old_value
64 when 'project_id'
65 when 'project_id'
65 p = Project.find_by_id(detail.value) and value = p.name if detail.value
66 p = Project.find_by_id(detail.value) and value = p.name if detail.value
66 p = Project.find_by_id(detail.old_value) and old_value = p.name if detail.old_value
67 p = Project.find_by_id(detail.old_value) and old_value = p.name if detail.old_value
67 when 'status_id'
68 when 'status_id'
68 s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value
69 s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value
69 s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value
70 s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value
70 when 'tracker_id'
71 when 'tracker_id'
71 t = Tracker.find_by_id(detail.value) and value = t.name if detail.value
72 t = Tracker.find_by_id(detail.value) and value = t.name if detail.value
72 t = Tracker.find_by_id(detail.old_value) and old_value = t.name if detail.old_value
73 t = Tracker.find_by_id(detail.old_value) and old_value = t.name if detail.old_value
73 when 'assigned_to_id'
74 when 'assigned_to_id'
74 u = User.find_by_id(detail.value) and value = u.name if detail.value
75 u = User.find_by_id(detail.value) and value = u.name if detail.value
75 u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
76 u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
76 when 'priority_id'
77 when 'priority_id'
77 e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value
78 e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value
78 e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
79 e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
79 when 'category_id'
80 when 'category_id'
80 c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
81 c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
81 c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
82 c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
82 when 'fixed_version_id'
83 when 'fixed_version_id'
83 v = Version.find_by_id(detail.value) and value = v.name if detail.value
84 v = Version.find_by_id(detail.value) and value = v.name if detail.value
84 v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
85 v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
85 when 'estimated_hours'
86 when 'estimated_hours'
86 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
87 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
87 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
88 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
88 end
89 end
89 when 'cf'
90 when 'cf'
90 custom_field = CustomField.find_by_id(detail.prop_key)
91 custom_field = CustomField.find_by_id(detail.prop_key)
91 if custom_field
92 if custom_field
92 label = custom_field.name
93 label = custom_field.name
93 value = format_value(detail.value, custom_field.field_format) if detail.value
94 value = format_value(detail.value, custom_field.field_format) if detail.value
94 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
95 old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
95 end
96 end
96 when 'attachment'
97 when 'attachment'
97 label = l(:label_attachment)
98 label = l(:label_attachment)
98 end
99 end
99 call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })
100 call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })
100
101
101 label ||= detail.prop_key
102 label ||= detail.prop_key
102 value ||= detail.value
103 value ||= detail.value
103 old_value ||= detail.old_value
104 old_value ||= detail.old_value
104
105
105 unless no_html
106 unless no_html
106 label = content_tag('strong', label)
107 label = content_tag('strong', label)
107 old_value = content_tag("i", h(old_value)) if detail.old_value
108 old_value = content_tag("i", h(old_value)) if detail.old_value
108 old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
109 old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
109 if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
110 if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
110 # Link to the attachment if it has not been removed
111 # Link to the attachment if it has not been removed
111 value = link_to_attachment(a)
112 value = link_to_attachment(a)
112 else
113 else
113 value = content_tag("i", h(value)) if value
114 value = content_tag("i", h(value)) if value
114 end
115 end
115 end
116 end
116
117
117 if !detail.value.blank?
118 if !detail.value.blank?
118 case detail.property
119 case detail.property
119 when 'attr', 'cf'
120 when 'attr', 'cf'
120 if !detail.old_value.blank?
121 if !detail.old_value.blank?
121 label + " " + l(:text_journal_changed, old_value, value)
122 label + " " + l(:text_journal_changed, old_value, value)
122 else
123 else
123 label + " " + l(:text_journal_set_to, value)
124 label + " " + l(:text_journal_set_to, value)
124 end
125 end
125 when 'attachment'
126 when 'attachment'
126 "#{label} #{value} #{l(:label_added)}"
127 "#{label} #{value} #{l(:label_added)}"
127 end
128 end
128 else
129 else
129 case detail.property
130 case detail.property
130 when 'attr', 'cf'
131 when 'attr', 'cf'
131 label + " " + l(:text_journal_deleted) + " (#{old_value})"
132 label + " " + l(:text_journal_deleted) + " (#{old_value})"
132 when 'attachment'
133 when 'attachment'
133 "#{label} #{old_value} #{l(:label_deleted)}"
134 "#{label} #{old_value} #{l(:label_deleted)}"
134 end
135 end
135 end
136 end
136 end
137 end
137
138
138 def issues_to_csv(issues, project = nil)
139 def issues_to_csv(issues, project = nil)
139 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
140 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
140 decimal_separator = l(:general_csv_decimal_separator)
141 decimal_separator = l(:general_csv_decimal_separator)
141 export = StringIO.new
142 export = StringIO.new
142 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
143 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
143 # csv header fields
144 # csv header fields
144 headers = [ "#",
145 headers = [ "#",
145 l(:field_status),
146 l(:field_status),
146 l(:field_project),
147 l(:field_project),
147 l(:field_tracker),
148 l(:field_tracker),
148 l(:field_priority),
149 l(:field_priority),
149 l(:field_subject),
150 l(:field_subject),
150 l(:field_assigned_to),
151 l(:field_assigned_to),
151 l(:field_category),
152 l(:field_category),
152 l(:field_fixed_version),
153 l(:field_fixed_version),
153 l(:field_author),
154 l(:field_author),
154 l(:field_start_date),
155 l(:field_start_date),
155 l(:field_due_date),
156 l(:field_due_date),
156 l(:field_done_ratio),
157 l(:field_done_ratio),
157 l(:field_estimated_hours),
158 l(:field_estimated_hours),
158 l(:field_created_on),
159 l(:field_created_on),
159 l(:field_updated_on)
160 l(:field_updated_on)
160 ]
161 ]
161 # Export project custom fields if project is given
162 # Export project custom fields if project is given
162 # otherwise export custom fields marked as "For all projects"
163 # otherwise export custom fields marked as "For all projects"
163 custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
164 custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
164 custom_fields.each {|f| headers << f.name}
165 custom_fields.each {|f| headers << f.name}
165 # Description in the last column
166 # Description in the last column
166 headers << l(:field_description)
167 headers << l(:field_description)
167 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
168 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
168 # csv lines
169 # csv lines
169 issues.each do |issue|
170 issues.each do |issue|
170 fields = [issue.id,
171 fields = [issue.id,
171 issue.status.name,
172 issue.status.name,
172 issue.project.name,
173 issue.project.name,
173 issue.tracker.name,
174 issue.tracker.name,
174 issue.priority.name,
175 issue.priority.name,
175 issue.subject,
176 issue.subject,
176 issue.assigned_to,
177 issue.assigned_to,
177 issue.category,
178 issue.category,
178 issue.fixed_version,
179 issue.fixed_version,
179 issue.author.name,
180 issue.author.name,
180 format_date(issue.start_date),
181 format_date(issue.start_date),
181 format_date(issue.due_date),
182 format_date(issue.due_date),
182 issue.done_ratio,
183 issue.done_ratio,
183 issue.estimated_hours.to_s.gsub('.', decimal_separator),
184 issue.estimated_hours.to_s.gsub('.', decimal_separator),
184 format_time(issue.created_on),
185 format_time(issue.created_on),
185 format_time(issue.updated_on)
186 format_time(issue.updated_on)
186 ]
187 ]
187 custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
188 custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
188 fields << issue.description
189 fields << issue.description
189 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
190 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
190 end
191 end
191 end
192 end
192 export.rewind
193 export.rewind
193 export
194 export
194 end
195 end
195 end
196 end
General Comments 0
You need to be logged in to leave comments. Login now