OSDN Git Service

trunk moved from /trunk/redmine to /trunk
[redminele/redmine.git] / app / helpers / issues_helper.rb
1 # redMine - project management software\r
2 # Copyright (C) 2006  Jean-Philippe Lang\r
3 #\r
4 # This program is free software; you can redistribute it and/or\r
5 # modify it under the terms of the GNU General Public License\r
6 # as published by the Free Software Foundation; either version 2\r
7 # of the License, or (at your option) any later version.\r
8\r
9 # This program is distributed in the hope that it will be useful,\r
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 # GNU General Public License for more details.\r
13\r
14 # You should have received a copy of the GNU General Public License\r
15 # along with this program; if not, write to the Free Software\r
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
17 \r
18 module IssuesHelper\r
19 \r
20   def show_detail(detail, no_html=false)\r
21     case detail.property\r
22     when 'attr'\r
23       label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)   \r
24       case detail.prop_key\r
25       when 'due_date', 'start_date'\r
26         value = format_date(detail.value.to_date) if detail.value\r
27         old_value = format_date(detail.old_value.to_date) if detail.old_value\r
28       when 'status_id'\r
29         s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value\r
30         s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value\r
31       when 'assigned_to_id'\r
32         u = User.find_by_id(detail.value) and value = u.name if detail.value\r
33         u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value\r
34       when 'priority_id'\r
35         e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value\r
36         e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value\r
37       when 'category_id'\r
38         c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value\r
39         c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value\r
40       when 'fixed_version_id'\r
41         v = Version.find_by_id(detail.value) and value = v.name if detail.value\r
42         v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value\r
43       end\r
44     when 'cf'\r
45       custom_field = CustomField.find_by_id(detail.prop_key)\r
46       if custom_field\r
47         label = custom_field.name\r
48         value = format_value(detail.value, custom_field.field_format) if detail.value\r
49         old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value\r
50       end\r
51     end\r
52        \r
53     label ||= detail.prop_key\r
54     value ||= detail.value\r
55     old_value ||= detail.old_value\r
56     \r
57     unless no_html\r
58       label = content_tag('strong', label)\r
59       old_value = content_tag("i", old_value) if old_value\r
60       old_value = content_tag("strike", old_value) if old_value and !value\r
61       value = content_tag("i", value) if value\r
62     end\r
63     \r
64     if value\r
65       if old_value\r
66         label + " " + l(:text_journal_changed, old_value, value)\r
67       else\r
68         label + " " + l(:text_journal_set_to, value)\r
69       end\r
70     else\r
71       label + " " + l(:text_journal_deleted) + " (#{old_value})"\r
72     end\r
73   end
74 end