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);
clearMarker();
OSM.router.withoutMoveListener(function () {
map.setView(OSM.home, 15, { reset: true });
});
marker = L.marker(OSM.home, {
icon: OSM.getUserIcon(),
title: I18n.t("javascripts.home.marker_title")
}).addTo(map);
if (OSM.home) {
OSM.router.withoutMoveListener(function () {
map.setView(OSM.home, 15, { reset: true });
});
marker = L.marker(OSM.home, {
icon: OSM.getUserIcon(),
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 () {
clearMarker();
$("#browse_status").empty();
};
return page;

View file

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

View file

@ -45,4 +45,13 @@ class AccountHomeTest < ApplicationSystemTestCase
click_on "test user"
assert_no_link "Go to Home Location"
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