]> git.openstreetmap.org Git - rails.git/commitdiff
Display icon for current note only if this icon is defined
authorAnton Khorev <tony29@yandex.ru>
Sun, 9 Oct 2022 05:03:14 +0000 (08:03 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 9 Oct 2022 05:03:14 +0000 (08:03 +0300)
app/assets/javascripts/leaflet.map.js
test/system/index_test.rb

index b2d4abcb72719fd4b93f4bd218c29e48ebaee441..44aa530d9b39e2dd4aa8399dba5cedbca42b4500 100644 (file)
@@ -261,11 +261,13 @@ L.OSM.Map = L.Map.extend({
 
       L.circleMarker(object.latLng, haloStyle).addTo(this._objectLayer);
 
 
       L.circleMarker(object.latLng, haloStyle).addTo(this._objectLayer);
 
-      L.marker(object.latLng, {
-        icon: object.icon,
-        opacity: 1,
-        interactive: true
-      }).addTo(this._objectLayer);
+      if (object.icon) {
+        L.marker(object.latLng, {
+          icon: object.icon,
+          opacity: 1,
+          interactive: true
+        }).addTo(this._objectLayer);
+      }
 
       if (callback) callback(this._objectLayer.getBounds());
     } else { // element or changeset handled by L.OSM.DataLayer
 
       if (callback) callback(this._objectLayer.getBounds());
     } else { // element or changeset handled by L.OSM.DataLayer
index bb23cee60180aed99fbe388898735c80078dc099..1167797c5b8b85781a91e479fa21553c6cc22b6b 100644 (file)
@@ -18,4 +18,23 @@ class IndexTest < ApplicationSystemTestCase
     find("#sidebar .btn-close").click
     assert_no_selector "#editanchor[href*='?note=#{note.id}#']"
   end
     find("#sidebar .btn-close").click
     assert_no_selector "#editanchor[href*='?note=#{note.id}#']"
   end
+
+  test "can navigate from hidden note to visible note" do
+    sign_in_as(create(:moderator_user))
+    hidden_note = create(:note, :status => "hidden")
+    create(:note_comment, :note => hidden_note, :body => "this-is-a-hidden-note")
+    position = (1.003 * GeoRecord::SCALE).to_i
+    visible_note = create(:note, :latitude => position, :longitude => position)
+    create(:note_comment, :note => visible_note, :body => "this-is-a-visible-note")
+
+    visit root_path(:anchor => "map=15/1/1") # view place of hidden note in case it is not rendered during browse_note_path(hidden_note)
+    visit browse_note_path(hidden_note)
+    find(".leaflet-control.control-layers .control-button").click
+    find("#map-ui .overlay-layers .form-check-label", :text => "Map Notes").click
+    visible_note_marker = find(".leaflet-marker-icon[title=this-is-a-visible-note]")
+    assert_selector "#sidebar", :text => "this-is-a-hidden-note"
+
+    visible_note_marker.click
+    assert_selector "#sidebar", :text => "this-is-a-visible-note"
+  end
 end
 end