]> git.openstreetmap.org Git - rails.git/commitdiff
Show alert on account home page if home location is not set
authorAnton Khorev <tony29@yandex.ru>
Thu, 27 Jun 2024 01:02:38 +0000 (04:02 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 15 Feb 2025 16:02:30 +0000 (19:02 +0300)
app/assets/javascripts/index/home.js
config/locales/en.yml
test/system/account_home_test.rb

index d478625dcc70ee56226511c7f70bf9d72865cc29..7e297b724f4ad7da2fac606c92a690e803589bad 100644 (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;
index 19cf8001ecc6f5d0ef0a2460bde213828b9cb78d..5f9f706a0032937d9c8c34add43c3d0495ffbca1 100644 (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"
index 0d0e10615a0d0a70865d13c4297a15ed21d0255b..813c45ec8d483cccec83087d31522be4baeaee26 100644 (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