You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issues_helper.rb 3.2KB

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