X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/4b33f145c7966710e537531261e04d2596159049..5620e337719f6e64efaf77ec702c7d6848cc7255:/redmine/redmine_publications/lib/issue_publication_hook.rb
diff --git a/redmine/redmine_publications/lib/issue_publication_hook.rb b/redmine/redmine_publications/lib/issue_publication_hook.rb
index 4cfc3ba5..77fa215e 100644
--- a/redmine/redmine_publications/lib/issue_publication_hook.rb
+++ b/redmine/redmine_publications/lib/issue_publication_hook.rb
@@ -1,16 +1,36 @@
# Provides a link to the document on the platform
class IssuesPublicationHook < Redmine::Hook::ViewListener
+
def view_issues_show_details_bottom(context)
- result = "
Source File(s): | "
- names = context[:issue].source_files.map {|name| "" + name + ""}
- result << names.join(', ')
- result + " |
"
+ # TODO: zÅapaÄ wyjÄ
tek konwersji
+ if context[:issue].tracker_id == Setting.plugin_redmine_publications[:tracker].to_i
+ result = "Publication(s): | "
+ names = context[:issue].publication_names {|name| "" + name + ""}
+ result << names.join(', ')
+ result << " |
"
+ end
end
def controller_issues_edit_before_save(context)
- pub_field = context[:params][:issue_source_files]
- context[:issue].source_files = pub_field
+ 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