From: Anton Khorev Date: Mon, 9 Dec 2024 10:04:32 +0000 (+0300) Subject: Allow to specify browse icon priorities X-Git-Tag: live~6^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/5b5ffaf90f54b19379223ee912fe6a4f59234fcd?hp=f051a7c1f5d1999558caa9d3cbe8c36f8ac39c9b Allow to specify browse icon priorities --- diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 5cc12bb00..6619a1e92 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -1,6 +1,6 @@ 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 @@ -8,7 +8,7 @@ module BrowseHelper 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 diff --git a/config/browse_icons.yml b/config/browse_icons.yml index d59c23682..f24d7676c 100644 --- a/config/browse_icons.yml +++ b/config/browse_icons.yml @@ -144,7 +144,7 @@ railway: 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" } diff --git a/config/initializers/browse_icons.rb b/config/initializers/browse_icons.rb index cb53848e8..a55df97b6 100644 --- a/config/initializers/browse_icons.rb +++ b/config/initializers/browse_icons.rb @@ -2,7 +2,9 @@ begin 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