[openstreetmap/openstreetmap-website] Split directions engine select into modes and providers (PR #5652)
Tom Hughes
notifications at github.com
Tue Feb 25 20:41:51 UTC 2025
@tomhughes commented on this pull request.
> + </defs>
+ </svg>
+ </div>
+ <div class="btn-group routing_modes" role="group">
+ <% %w[car bicycle foot]
+ .map { |id| { :id => id, :title => t("site.search.modes.#{id}") } }
+ .sort_by { |mode| mode[:title] }
+ .each do |mode| %>
+ <input type="radio" class="btn-check" name="modes" id="<%= mode[:id] %>" autocomplete="off" disabled>
+ <label class="btn btn-outline-secondary px-2" for="<%= mode[:id] %>" title="<%= mode[:title] %>">
+ <svg class="d-block" width="16" height="16" fill="currentColor">
+ <use href="#icon-<%= mode[:id] %>"></use>
+ </svg>
+ </label>
+ <% end %>
+ </div>
This goes to the previous discussion about sorting, but the above is far more complicated than it really needs to be, and all so we can put the icons in a different order for different languages which seems quite mad to me.
I would just make this a fixed order then we don't need to predefined the icons in a hidden block so that we can sort them.
> + <% %w[car bicycle foot]
+ .map { |id| { :id => id, :title => t("site.search.modes.#{id}") } }
+ .sort_by { |mode| mode[:title] }
+ .each do |mode| %>
+ <input type="radio" class="btn-check" name="modes" id="<%= mode[:id] %>" autocomplete="off" disabled>
+ <label class="btn btn-outline-secondary px-2" for="<%= mode[:id] %>" title="<%= mode[:title] %>">
+ <svg class="d-block" width="16" height="16" fill="currentColor">
+ <use href="#icon-<%= mode[:id] %>"></use>
+ </svg>
+ </label>
+ <% end %>
+ </div>
+ <select class="routing_engines form-select py-1 px-2" name="routing_engines">
+ <% %w[fossgis_osrm graphhopper fossgis_valhalla]
+ .map { |id| { :id => id, :title => t("site.search.providers.#{id}") } }
+ .sort_by { |engine| engine[:title] }
I guess this does need some sort of order to be applied because the order in which the engines are registered is probably not well defined but I'd be inclined to sort by the provider ID rather than the translated name so that the order is consistent across languages.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5652#pullrequestreview-2642410302
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5652/review/2642410302 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250225/4f70c33c/attachment.htm>
More information about the rails-dev
mailing list