]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/reports_helper.rb
Merge pull request #5070 from tomhughes/rails72
[rails.git] / app / helpers / reports_helper.rb
index 70c9adac6527d59b1140717df537e7c812ef911f..57b786792106f40eab119d2716b98cf8e1417c71 100644 (file)
@@ -1,5 +1,16 @@
+require "ostruct"
+
 module ReportsHelper
+  Category = Struct.new(:id, :label)
+
   def report_link(name, reportable)
     link_to name, new_report_url(:reportable_id => reportable.id, :reportable_type => reportable.class.name)
   end
+
+  # Convert a list of strings into objects with methods that the collection_radio_buttons helper expects
+  def report_categories(reportable)
+    Report.categories_for(reportable).map do |c|
+      Category.new(c, t(".categories.#{reportable.class.name.underscore}.#{c}_label"))
+    end
+  end
 end