From: Anton Khorev Date: Wed, 17 Jul 2024 13:43:52 +0000 (+0300) Subject: Set search input value to 'lat, lon' params if query param is missing X-Git-Tag: live~413^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0e3f0fbfd4dec912420e51cbf46373fa540a4651?hp=-c Set search input value to 'lat, lon' params if query param is missing --- 0e3f0fbfd4dec912420e51cbf46373fa540a4651 diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 2f3882e3a..476ad30a1 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -118,8 +118,13 @@ OSM.Search = function (map) { page.pushstate = page.popstate = function (path) { var params = Qs.parse(path.substring(path.indexOf("?") + 1)); - $(".search_form input[name=query]").val(params.query); - $(".describe_location").hide(); + if (params.query) { + $(".search_form input[name=query]").val(params.query); + $(".describe_location").hide(); + } else if (params.lat && params.lon) { + $(".search_form input[name=query]").val(params.lat + ", " + params.lon); + $(".describe_location").hide(); + } OSM.loadSidebarContent(path, page.load); }; diff --git a/test/system/search_test.rb b/test/system/search_test.rb new file mode 100644 index 000000000..8cda1f74e --- /dev/null +++ b/test/system/search_test.rb @@ -0,0 +1,14 @@ +require "application_system_test_case" + +class SearchTest < ApplicationSystemTestCase + test "click on 'where is this' sets search input value" do + stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?}) + .to_return(:status => 404) + + visit "/#map=7/1.234/6.789" + + assert_field "Search", :with => "" + click_on "Where is this?" + assert_field "Search", :with => "1.234, 6.789" + end +end