Show only description as a marker tooltip in note layer
This commit is contained in:
parent
09e802b86c
commit
db08587325
2 changed files with 48 additions and 1 deletions
|
@ -40,9 +40,16 @@ OSM.initializeNotesLayer = function (map) {
|
||||||
if (marker) {
|
if (marker) {
|
||||||
marker.setIcon(noteIcons[feature.properties.status]);
|
marker.setIcon(noteIcons[feature.properties.status]);
|
||||||
} else {
|
} else {
|
||||||
|
let title;
|
||||||
|
const description = feature.properties.comments[0];
|
||||||
|
|
||||||
|
if (description?.action === "opened") {
|
||||||
|
title = description.text;
|
||||||
|
}
|
||||||
|
|
||||||
marker = L.marker(feature.geometry.coordinates.reverse(), {
|
marker = L.marker(feature.geometry.coordinates.reverse(), {
|
||||||
icon: noteIcons[feature.properties.status],
|
icon: noteIcons[feature.properties.status],
|
||||||
title: feature.properties.comments[0].text,
|
title,
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
interactive: true
|
interactive: true
|
||||||
});
|
});
|
||||||
|
|
40
test/system/note_layer_test.rb
Normal file
40
test/system/note_layer_test.rb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
require "application_system_test_case"
|
||||||
|
|
||||||
|
class NoteLayerTest < ApplicationSystemTestCase
|
||||||
|
test "note marker should have description as a title" do
|
||||||
|
position = (1.1 * GeoRecord::SCALE).to_i
|
||||||
|
create(:note, :latitude => position, :longitude => position) do |note|
|
||||||
|
create(:note_comment, :note => note, :body => "Note description")
|
||||||
|
end
|
||||||
|
|
||||||
|
visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
|
||||||
|
all "img.leaflet-marker-icon", :count => 1 do |marker|
|
||||||
|
assert_equal "Note description", marker["title"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "note marker should not have a title if the note has no visible description" do
|
||||||
|
position = (1.1 * GeoRecord::SCALE).to_i
|
||||||
|
create(:note, :latitude => position, :longitude => position) do |note|
|
||||||
|
create(:note_comment, :note => note, :body => "Note description is hidden", :visible => false)
|
||||||
|
create(:note_comment, :note => note, :body => "Note comment visible", :event => "commented")
|
||||||
|
end
|
||||||
|
|
||||||
|
visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
|
||||||
|
all "img.leaflet-marker-icon", :count => 1 do |marker|
|
||||||
|
assert_equal "", marker["title"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "note marker should not have a title if the note has no visible description and comments" do
|
||||||
|
position = (1.1 * GeoRecord::SCALE).to_i
|
||||||
|
create(:note, :latitude => position, :longitude => position) do |note|
|
||||||
|
create(:note_comment, :note => note, :body => "Note description is hidden", :visible => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
visit root_path(:anchor => "map=18/1.1/1.1&layers=N")
|
||||||
|
all "img.leaflet-marker-icon", :count => 1 do |marker|
|
||||||
|
assert_equal "", marker["title"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue