Skip to content

Commit

Permalink
Show alert on account home page if home location is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Jan 15, 2025
1 parent 4e764cf commit 543a8ea
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
23 changes: 16 additions & 7 deletions app/assets/javascripts/index/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,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"
Expand Down
9 changes: 9 additions & 0 deletions test/system/account_home_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 543a8ea

Please sign in to comment.