Show alert on account home page if home location is not set

This commit is contained in:
Anton Khorev 2024-06-27 04:02:38 +03:00
parent 5c019cd2ee
commit ae89ed45e5
3 changed files with 26 additions and 7 deletions

View file

@ -12,17 +12,26 @@ OSM.Home = function (map) {
map.setSidebarOverlaid(true); map.setSidebarOverlaid(true);
clearMarker(); clearMarker();
OSM.router.withoutMoveListener(function () { if (OSM.home) {
map.setView(OSM.home, 15, { reset: true }); OSM.router.withoutMoveListener(function () {
}); map.setView(OSM.home, 15, { reset: true });
marker = L.marker(OSM.home, { });
icon: OSM.getUserIcon(), marker = L.marker(OSM.home, {
title: I18n.t("javascripts.home.marker_title") icon: OSM.getUserIcon(),
}).addTo(map); title: I18n.t("javascripts.home.marker_title")
}).addTo(map);
} else {
$("#browse_status").html(
$("<div class='m-2 alert alert-warning'>").text(
I18n.t("javascripts.home.not_set")
)
);
}
}; };
page.unload = function () { page.unload = function () {
clearMarker(); clearMarker();
$("#browse_status").empty();
}; };
return page; return page;

View file

@ -3318,6 +3318,7 @@ en:
centre_map: Centre map here centre_map: Centre map here
home: home:
marker_title: My home location marker_title: My home location
not_set: Home location is not set for your account
redactions: redactions:
edit: edit:
heading: "Edit Redaction" heading: "Edit Redaction"

View file

@ -45,4 +45,13 @@ class AccountHomeTest < ApplicationSystemTestCase
click_on "test user" click_on "test user"
assert_no_link "Go to Home Location" assert_no_link "Go to Home Location"
end end
test "account home page shows a warning when visited by users without home location" do
user = create(:user, :display_name => "test user")
sign_in_as(user)
visit account_home_path
assert_no_selector "img.leaflet-marker-icon"
assert_text "Home location is not set"
end
end end