From c3755c2f23e727850560757cbcca0c52ef47f670 Mon Sep 17 00:00:00 2001 From: mmd-osm Date: Sun, 27 Jul 2025 21:27:09 +0200 Subject: [PATCH] Bootstrap modal instead of alert() --- app/assets/javascripts/download_util.js | 13 +++++++++---- app/views/layouts/_header.html.erb | 16 ++++++++++++++++ config/locales/en.yml | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/download_util.js b/app/assets/javascripts/download_util.js index 21b7cc246..a2102bd52 100644 --- a/app/assets/javascripts/download_util.js +++ b/app/assets/javascripts/download_util.js @@ -10,14 +10,20 @@ URL.revokeObjectURL(url); }; + OSM.showAlert = function (message) { + const modalBody = document.getElementById("osm_alert_message"); + modalBody.textContent = message; + const alertModal = new bootstrap.Modal(document.getElementById("osm_alert_modal")); + alertModal.show(); + }; + class DownloadUtil { static async handleExportSuccess(fetchResponse, filename) { try { const blob = await fetchResponse.response.blob(); OSM.downloadBlob(blob, filename); } catch (err) { - // eslint-disable-next-line no-alert - alert(OSM.i18n.t("javascripts.share.export_failed", { reason: "(blob error)" })); + OSM.showAlert(OSM.i18n.t("javascripts.share.export_failed", { reason: "(blob error)" })); } } @@ -34,8 +40,7 @@ } catch (err) { detailMessage = "(unknown)"; } - // eslint-disable-next-line no-alert - alert(OSM.i18n.t("javascripts.share.export_failed", { reason: detailMessage })); + OSM.showAlert(OSM.i18n.t("javascripts.share.export_failed", { reason: detailMessage })); } static getTurboBlobHandler(filename) { diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index b8fcfc13a..31f3f37b0 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -127,3 +127,19 @@ + + diff --git a/config/locales/en.yml b/config/locales/en.yml index ac3ff3932..47284c88c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3399,6 +3399,8 @@ en: sorry: "Sorry, note #%{id} could not be found." javascripts: close: Close + alert: Alert + ok: OK share: title: "Share" view_larger_map: "View Larger Map" -- 2.39.5