From 37e631df4493615977a7e41c19ff317768a13abb Mon Sep 17 00:00:00 2001 From: mmd-osm Date: Sat, 20 Sep 2025 20:30:50 +0200 Subject: [PATCH] Added confirmation modal dialog for Overpass API export --- app/assets/javascripts/index/export.js | 31 ++++++++++++++++++++++++++ app/views/site/export.html.erb | 22 ++++++++++++++++++ config/locales/en.yml | 5 +++++ 3 files changed, 58 insertions(+) diff --git a/app/assets/javascripts/index/export.js b/app/assets/javascripts/index/export.js index 4e4e0b5ab..fc9db9d41 100644 --- a/app/assets/javascripts/index/export.js +++ b/app/assets/javascripts/index/export.js @@ -37,6 +37,28 @@ OSM.Export = function (map) { validateControls(); } + async function showConfirmationModal() { + const $modal = $("#export_confirmation"); + const $downloadButton = $modal.find("[data-action=\"download\"]"); + $modal.appendTo("body").modal("show"); + + return new Promise(resolve => { + const onOkClick = () => { + resolve(true); + $modal.modal("hide"); + }; + + const onModalHidden = () => { + $downloadButton.off("click", onOkClick); + $modal.off("hidden.bs.modal", onModalHidden); + resolve(false); + }; + + $downloadButton.on("click", onOkClick); + $modal.on("hidden.bs.modal", onModalHidden); + }); + } + function setBounds(bounds) { const truncated = [bounds.getSouthWest(), bounds.getNorthEast()] .map(c => OSM.cropLocation(c, map.getZoom())); @@ -83,6 +105,15 @@ OSM.Export = function (map) { event.detail.fetchOptions.headers.Accept = "application/xml"; }); + $("#export_overpass").on("click", async function (event) { + event.preventDefault(); + const downloadUrl = $(this).attr("href"); + const confirmed = await showConfirmationModal(); + if (confirmed) { + window.location.href = downloadUrl; + } + }); + update(); return map.getState(); }; diff --git a/app/views/site/export.html.erb b/app/views/site/export.html.erb index 5978f992a..8dc3bffdb 100644 --- a/app/views/site/export.html.erb +++ b/app/views/site/export.html.erb @@ -48,3 +48,25 @@
<%= t ".too_large.other.description" %>
<% end %> + + diff --git a/config/locales/en.yml b/config/locales/en.yml index 8118dfe4c..4d9ad71f3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2623,6 +2623,11 @@ en: description: "Additional sources listed on the OpenStreetMap Wiki" export_button: "Export" export_download: "Downloading..." + confirmation: + header: Download XML Data + body: Do you want to download map data for this area in XML format? Note that large areas may take some time to download. + cancel: Cancel + download: Download fixthemap: title: Report a problem / Fix the map how_to_help: -- 2.39.5