]> git.openstreetmap.org Git - rails.git/commitdiff
Move search fetch url construction to controller
authorAnton Khorev <tony29@yandex.ru>
Sun, 30 Mar 2025 03:04:31 +0000 (06:04 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 31 Mar 2025 16:34:11 +0000 (19:34 +0300)
app/controllers/geocoder_controller.rb
app/views/geocoder/search.html.erb

index f23448bffc08584391f162074d723c1e38d1c987..0ccd1d14badb5ba15cd9562f2cd2bd8ccaae7164 100644 (file)
@@ -13,10 +13,10 @@ class GeocoderController < ApplicationController
     @sources = []
 
     if @params[:lat] && @params[:lon]
-      @sources.push(:name => "latlon", :url => root_path)
-      @sources.push(:name => "osm_nominatim_reverse", :url => nominatim_reverse_url(:format => "html"))
+      @sources.push(:name => "latlon", :url => root_path, :fetch_url => url_for(@params.merge(:action => "search_latlon")))
+      @sources.push(:name => "osm_nominatim_reverse", :url => nominatim_reverse_url(:format => "html"), :fetch_url => url_for(@params.merge(:action => "search_osm_nominatim_reverse")))
     elsif @params[:query]
-      @sources.push(:name => "osm_nominatim", :url => nominatim_url(:format => "html"))
+      @sources.push(:name => "osm_nominatim", :url => nominatim_url(:format => "html"), :fetch_url => url_for(@params.merge(:action => "search_osm_nominatim")))
     end
 
     if @sources.empty?
index 56f468f2f655a1303038a237173aca13550d7099..efbaab253d4dffbf0fa333e221fefa5620d3cde0 100644 (file)
@@ -6,7 +6,7 @@
   <h4>
     <%= link_to t(".title.#{source[:name]}"), source[:url].to_s %>
   </h4>
-  <div class="search_results_entry mx-n3" data-href="<%= url_for @params.merge(:action => "search_#{source[:name]}") %>">
+  <div class="search_results_entry mx-n3" data-href="<%= source[:fetch_url] %>">
     <div class="text-center loader">
       <div class="spinner-border" role="status">
         <span class="visually-hidden"><%= t("browse.start_rjs.loading") %></span>