9c9723398a83127f17e1be7ed954bf24350b92ae
[redakcja_redmine.git] / lib / issue_publication_hook.rb
1 # Provides a link to the document on the platform
2 class IssuesPublicationHook < Redmine::Hook::ViewListener
3
4   def view_issues_show_details_bottom(context)
5         # TODO: złapać wyjątek konwersji
6         if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i
7           result = "<tr><td><b>Publication(s):</b></td><td>"
8           names = context[:issue].publication_names {|name| "<span>" + name + "</span>"} 
9           result << names.join(', ')
10           result << "</td></tr>"
11         end
12   end
13
14   def controller_issues_edit_before_save(context)
15         if context[:issue].tracker_id == Setting.plugin_redmine_publications['tracker'].to_i
16           pub_field = context[:params][:publications]
17           context[:issue].publication_names = pub_field.split(',').map { |n| n.strip }
18         end
19   end
20
21   render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub'
22 end