-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathhelper_issues_show_detail_after_setting_hook.rb
More file actions
30 lines (28 loc) · 1.11 KB
/
helper_issues_show_detail_after_setting_hook.rb
File metadata and controls
30 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module RedmineContracts
module Hooks
class HelperIssuesShowDetailAfterSettingHook < Redmine::Hook::ViewListener
# Deliverable changes for the journal use the Deliverable subject
# instead of the id
#
# Context:
# * :detail => Detail about the journal change
#
def helper_issues_show_detail_after_setting(context = { })
# This will be skipped in ChiliProject 2.x because
# acts_as_journalized overrides the prop_key with the label
# 'deliverable_id' becomes 'Deliverable' (i18n)
#
# register_on_journal_formatter is used for ChiliProject 2.x support
# TODO Later: Overwritting the caller is bad juju
if context[:detail].prop_key == 'deliverable_id'
context[:detail].reload
d = Deliverable.find_by_id(context[:detail].value)
context[:detail].value = d.title if d.present? && d.title.present?
d = Deliverable.find_by_id(context[:detail].old_value)
context[:detail].old_value = d.title if d.present? && d.title.present?
end
''
end
end
end
end