module BrowseHelper
def element_icon(type, object)
- selected_icon_data = { :filename => "#{type}.svg" }
+ selected_icon_data = { :filename => "#{type}.svg", :priority => 1 }
unless object.redacted?
target_tags = object.tags.find_all { |k, _v| BROWSE_ICONS.key? k }.sort
target_tags.each do |k, v|
icon_data = BROWSE_ICONS[k][v] || BROWSE_ICONS[k][:*]
- selected_icon_data = icon_data if icon_data
+ selected_icon_data = icon_data if icon_data && icon_data[:priority] > selected_icon_data[:priority]
end
end
tram: { filename: "tram.20.png" }
shop:
- :*: { filename: "shop_convenience.p.16.png" }
+ :*: { filename: "shop_convenience.p.16.png", priority: 20 }
alcohol: { filename: "shop_alcohol.16.png" }
bakery: { filename: "shop_bakery.16.png" }
bicycle: { filename: "shop_bicycle.16.png" }
BROWSE_ICONS = YAML.load_file(Rails.root.join("config/browse_icons.yml")).transform_values do |tag_key_data|
transformed_tag_key_data = {}
tag_key_data.each do |tag_value, tag_value_data|
- transformed_tag_key_data[tag_value] = tag_value_data.deep_symbolize_keys
+ tag_value_data = tag_value_data.deep_symbolize_keys
+ tag_value_data[:priority] ||= tag_value == :* ? 10 : 100
+ transformed_tag_key_data[tag_value] = tag_value_data
end
transformed_tag_key_data
end