From 38c22e2f927b751215443303897969407a65cbaa Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 14 Sep 2011 13:30:09 -0700 Subject: [PATCH] Workaround a regression in ChiliProject 2.x with setting journal attributes https://www.chiliproject.org/issues/622 --- app/models/deliverable.rb | 5 +++++ .../helper_issues_show_detail_after_setting_hook.rb | 5 +++++ lib/redmine_contracts/patches/issue_patch.rb | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/app/models/deliverable.rb b/app/models/deliverable.rb index 78a395d..0921c25 100644 --- a/app/models/deliverable.rb +++ b/app/models/deliverable.rb @@ -280,6 +280,11 @@ class Deliverable < ActiveRecord::Base end end + # Required attribute for AAJ's JournalFormatter + def name + title + end + # Accessors from the budget plugin that need to be wrapped def subject warn "[DEPRECATION] Deliverable#subject is deprecated. Please use Deliverable#title instead." diff --git a/lib/redmine_contracts/hooks/helper_issues_show_detail_after_setting_hook.rb b/lib/redmine_contracts/hooks/helper_issues_show_detail_after_setting_hook.rb index d3af4c8..86c9aa2 100644 --- a/lib/redmine_contracts/hooks/helper_issues_show_detail_after_setting_hook.rb +++ b/lib/redmine_contracts/hooks/helper_issues_show_detail_after_setting_hook.rb @@ -8,6 +8,11 @@ module RedmineContracts # * :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 diff --git a/lib/redmine_contracts/patches/issue_patch.rb b/lib/redmine_contracts/patches/issue_patch.rb index f1157ad..f6bf31b 100644 --- a/lib/redmine_contracts/patches/issue_patch.rb +++ b/lib/redmine_contracts/patches/issue_patch.rb @@ -12,6 +12,17 @@ module RedmineContracts delegate :title, :to => :deliverable, :prefix => true, :allow_nil => true delegate :contract, :to => :deliverable, :allow_nil => true + # ChiliProject 2.x support for acts_as_journalized. + # Used to format the journal details on the Issue page + # + # See RedmineContracts::Hooks::HelperIssuesShowDetailAfterSettingHook + # for <2.x and Redmine version + # + # TODO: Will not support permissions or custom code in the formatter. + if Issue.respond_to?(:register_on_journal_formatter) + register_on_journal_formatter(:named_association, 'deliverable_id') + end + def contract_name contract.try(:name) end