From 397d30c4e9e607f380f293801041c48261ca53ca Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 15 Jan 2020 16:59:49 +0100 Subject: [PATCH 1/2] Add query-result classes for errors and nothing_found messages --- app/assets/javascripts/index/query.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 514d6dbb2..7d02760ce 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -228,12 +228,14 @@ OSM.Query = function (map) { if (results.remark) { $("
  • ") + .addClass("query-result list-group-item") .text(I18n.t("javascripts.query.error", { server: url, error: results.remark })) .appendTo($ul); } if ($ul.find("li").length === 0) { $("
  • ") + .addClass("query-result list-group-item") .text(I18n.t("javascripts.query.nothing_found")) .appendTo($ul); } @@ -242,6 +244,7 @@ OSM.Query = function (map) { $section.find(".loader").stopTime("loading").hide(); $("
  • ") + .addClass("query-result list-group-item") .text(I18n.t("javascripts.query." + status, { server: url, error: error })) .appendTo($ul); } From a3795cddbb1e4ec7a697a78645d7df880bd690b3 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 15 Jan 2020 17:00:58 +0100 Subject: [PATCH 2/2] Move the search results to use list-group-flush --- app/assets/javascripts/index/search.js | 6 +++--- app/assets/stylesheets/common.scss | 7 ------- app/views/geocoder/results.html.erb | 10 +++++++--- test/controllers/geocoder_controller_test.rb | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index ba66f4782..9ed243466 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -45,9 +45,9 @@ OSM.Search = function (map) { $("#sidebar_content") .on("click", ".search_more a", clickSearchMore) .on("click", ".search_results_entry a.set_position", clickSearchResult) - .on("mouseover", "p.search_results_entry:has(a.set_position)", showSearchResult) - .on("mouseout", "p.search_results_entry:has(a.set_position)", hideSearchResult) - .on("mousedown", "p.search_results_entry:has(a.set_position)", function () { + .on("mouseover", "li.search_results_entry:has(a.set_position)", showSearchResult) + .on("mouseout", "li.search_results_entry:has(a.set_position)", hideSearchResult) + .on("mousedown", "li.search_results_entry:has(a.set_position)", function () { var moved = false; $(this).one("click", function (e) { if (!moved && !$(e.target).is("a")) { diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index abae98392..5635e3f9d 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -939,15 +939,8 @@ header .search_forms, /* Rules for search sidebar */ #sidebar .search_results_entry { - ul { - padding: 0; - } - ul li { - border-bottom: $keyline; cursor: pointer; - list-style-type: none; - &:first-child { border-top: $keyline; } &.selected { background: $list-highlight; } } diff --git a/app/views/geocoder/results.html.erb b/app/views/geocoder/results.html.erb index deec4ed39..94f19d2fe 100644 --- a/app/views/geocoder/results.html.erb +++ b/app/views/geocoder/results.html.erb @@ -1,9 +1,13 @@ <% if @results.empty? %> -

    <%= t ".no_results" %>

    +
      +
    • + <%= t ".no_results" %> +
    • +
    <% else %> -
      +
        <% @results.each do |result| %> -
      • <%= result_to_html(result) %>

      • +
      • <%= result_to_html(result) %>
      • <% end %>
      <% if @more_params %> diff --git a/test/controllers/geocoder_controller_test.rb b/test/controllers/geocoder_controller_test.rb index f8a4eed19..0459eb294 100644 --- a/test/controllers/geocoder_controller_test.rb +++ b/test/controllers/geocoder_controller_test.rb @@ -489,11 +489,11 @@ class GeocoderControllerTest < ActionController::TestCase assert_select "ul.results-list", 0 else assert_select "ul.results-list", 1 do - assert_select "p.search_results_entry", results.count + assert_select "li.search_results_entry", results.count results.each do |result| attrs = result.collect { |k, v| "[data-#{k}='#{v}']" }.join("") - assert_select "p.search_results_entry a.set_position#{attrs}", result[:name] + assert_select "li.search_results_entry a.set_position#{attrs}", result[:name] end end end