From 906605feaebeb870d9161a74b919d618dc0d9a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonia=20P=C3=A9rez-Cerezo?= Date: Wed, 12 Mar 2025 14:55:55 +0100 Subject: [PATCH] Check if there is a path to save, abort saving if file dialog is cancelled --- frontend/common/map.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/common/map.js b/frontend/common/map.js index c5b0fc3..80066ce 100644 --- a/frontend/common/map.js +++ b/frontend/common/map.js @@ -93,13 +93,13 @@ async function updateBrouter () { markers[markers.length-1]._icon.classList.add("red"); markers[0]._icon.classList.add("green"); } + geojsons = []; if (markers.length < 2) { if (geojson != undefined) { map.removeLayer(geojson); } return; } - geojsons = []; for (let i = 0; i < markers.length - 1 ; i++) { const marker1 = markers[i].getLatLng(); const marker2 = markers[i+1].getLatLng(); @@ -154,7 +154,14 @@ async function pickDirectory(e){ document.getElementById("edit-mode").innerHTML = "save"; editMode = true; } else { + if (geojsons.length < 1) { + alert("There is no path to save!"); + return; + } const filename = window.prompt("Enter filename:", "test"); + if (filename === null) { + return; + } const dat = {type: "FeatureCollection", features: geojsons}; const file = await dirHandle.getFileHandle(`${filename}.geojson`, { create: true