X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/d940e6b2345b50ffbd50bbe5f508f6d4ff4e0054..f02d58db2f0a5f06c38d669c4b4c4fff95e55395:/redmine/redmine_publications/lib/issue_publication_hook.rb?ds=inline diff --git a/redmine/redmine_publications/lib/issue_publication_hook.rb b/redmine/redmine_publications/lib/issue_publication_hook.rb index 9c972339..77fa215e 100644 --- a/redmine/redmine_publications/lib/issue_publication_hook.rb +++ b/redmine/redmine_publications/lib/issue_publication_hook.rb @@ -3,7 +3,7 @@ class IssuesPublicationHook < Redmine::Hook::ViewListener def view_issues_show_details_bottom(context) # TODO: zÅapaÄ wyjÄ tek konwersji - if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i + if context[:issue].tracker_id == Setting.plugin_redmine_publications[:tracker].to_i result = "<tr><td><b>Publication(s):</b></td><td>" names = context[:issue].publication_names {|name| "<span>" + name + "</span>"} result << names.join(', ') @@ -12,11 +12,25 @@ class IssuesPublicationHook < Redmine::Hook::ViewListener end def controller_issues_edit_before_save(context) - if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i - pub_field = context[:params][:publications] - context[:issue].publication_names = pub_field.split(',').map { |n| n.strip } + if context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i + old_value = context[:issue].publication_names + new_value = context[:params][:publications].split(',').map { |n| n.strip } + context[:journal].details << JournalDetail.new( + :property => 'attr', :prop_key => "publications", + :old_value => old_value.join(', '), + :value => new_value.join(', ') ) unless new_value==old_value + context[:issue].publication_names = new_value end end + + def controller_issues_new_after_save(context) + if context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i + value = context[:params][:publications].split(',').map { |n| n.strip } + context[:issue].publication_names = value + context[:issue].save + end + end + render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub' end