]> git.openstreetmap.org Git - rails.git/blob - app/helpers/reports_helper.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / app / helpers / reports_helper.rb
1 # frozen_string_literal: true
2
3 require "ostruct"
4
5 module ReportsHelper
6   Category = Struct.new(:id, :label)
7
8   def report_link(name, reportable)
9     link_to name, new_report_url(:reportable_id => reportable.id, :reportable_type => reportable.class.name)
10   end
11
12   # Convert a list of strings into objects with methods that the collection_radio_buttons helper expects
13   def report_categories(reportable)
14     Report.categories_for(reportable).map do |c|
15       Category.new(c, t(".categories.#{reportable.class.name.underscore}.#{c}_label"))
16     end
17   end
18 end