From 189863fdb401aa43d294667974a7e648814d7086 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Fri, 22 Nov 2024 13:05:05 +0100 Subject: [PATCH] fix: postpone handling of location changed until async function is done --- .../webapp/templates/forecastConfigurationForm.ftl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/templates/forecastConfigurationForm.ftl b/src/main/webapp/templates/forecastConfigurationForm.ftl index 7d73b049..56c50f57 100755 --- a/src/main/webapp/templates/forecastConfigurationForm.ftl +++ b/src/main/webapp/templates/forecastConfigurationForm.ftl @@ -174,14 +174,15 @@ function callbackOnCloseLocationMap(poiData) { if(!poiData.pointOfInterestId) { - persistNewLocation(poiData); + persistNewLocation(poiData, handleLocationChanged); } else { selectPoi(selectLocationElement, poiData.pointOfInterestId); + handleLocationChanged(); } - handleLocationChanged(); + } - function persistNewLocation(poiData) { + function persistNewLocation(poiData, callback) { fetch("/rest/poi", { method: 'POST', headers: { @@ -197,7 +198,8 @@ renderPoiSelect(selectLocationElement, locationList, poi.pointOfInterestId); // Assuming that this is not a weather station, since weather stations cannot be created using the // map, the user must have created a .... MAYBE HANDLED AUTOMATICALLY?? by the change event?? - console.info("Point of interest successfully persisted", poi); + //console.info("Point of interest successfully persisted", poi); + callback(); }) .catch(error => { console.error("Unable to persist new point of interest", error); -- GitLab