Wyłapywanie tylko znanych skrótów klawiszowych.
[redakcja.git] / redmine / redmine_publications / lib / issue_publication_hook.rb
index 4cfc3ba..9c97233 100644 (file)
@@ -1,15 +1,21 @@
 # Provides a link to the document on the platform
 class IssuesPublicationHook < Redmine::Hook::ViewListener
 # Provides a link to the document on the platform
 class IssuesPublicationHook < Redmine::Hook::ViewListener
+
   def view_issues_show_details_bottom(context)
   def view_issues_show_details_bottom(context)
-        result = "<tr><td><b>Source File(s):</b></td><td>"
-       names = context[:issue].source_files.map {|name| "<span>" + name + "</span>"} 
-       result << names.join(', ')
-       result + "</td></tr>"
+       # TODO: złapać wyjątek konwersji
+       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(', ')
+         result << "</td></tr>"
+       end
   end
 
   def controller_issues_edit_before_save(context)
   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
+         pub_field = context[:params][:publications]
+         context[:issue].publication_names = pub_field.split(',').map { |n| n.strip }
+       end
   end
 
   render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub'
   end
 
   render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub'