From 8780c578a7ef3d186959e8e26ceaa9e5d9a4ce08 Mon Sep 17 00:00:00 2001 From: Lene Wasskog <lene.wasskog@nibio.no> Date: Tue, 29 Oct 2024 12:58:49 +0100 Subject: [PATCH] feat: Remember settings in septoriahumidity --- .../septoriahumiditymodelform.html | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html b/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html index dd0cd96e..8d062db8 100644 --- a/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html +++ b/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html @@ -65,7 +65,7 @@ <div class="form-group"> <div class="radio"> <label> - <input type="radio" name="weatherDataSourceType" id="grid" value="grid" checked onchange="displayCoordinatesInput()"> + <input type="radio" name="weatherDataSourceType" id="grid" value="grid" onchange="displayCoordinatesInput()"> for et punkt i kartet </label> <div id="input-coordinates"> @@ -255,10 +255,9 @@ const selectedLongitude = coordinatesData ? coordinatesData.longitude : undefined; if(selectedLatitude && selectedLongitude) { - console.error("Coordinates selected!") inputLatitudeElement.value = selectedLatitude; inputLongitudeElement.value = selectedLongitude; - getTimezone(selectedLatitude, selectedLongitude); + getTimezoneForPoint(selectedLatitude, selectedLongitude); } } @@ -274,6 +273,7 @@ window.openCoordinatesMap = () => { if (inputLatitudeElement.value && inputLongitudeElement.value) { + console.info(`Open map for lat=${parseFloat(inputLatitudeElement.value)} lon=${parseFloat(inputLatitudeElement.value)}`) selectedPoint = 1; selectedFeature = { "type": "FeatureCollection", "features": [ @@ -331,9 +331,10 @@ document.getElementById("grid").checked = true; document.getElementById('input-weatherstation').style.display="none"; document.getElementById('input-coordinates').style.display="block"; + getTimezoneForSelectedPoint() } - const getTimezone = (latitude, longitude) => { + const getTimezoneForPoint = (latitude, longitude) => { getLocationInformation(latitude, longitude).then(locationInfo => { theForm["timezone"].value = locationInfo.timezone; document.getElementById("gridPointInfo").innerHTML = `<b>Sted</b> ${locationInfo.location}<br> @@ -343,10 +344,24 @@ }); } + const getTimezoneForSelectedPoint = () => { + const lat = theForm["latitude"].value; + const lon = theForm["longitude"].value; + if(lat && lon) { + getTimezoneForPoint(lat, lon) + } else { + console.info("Latitude and longitude not set in form, cannot get timezone information") + } + } + var danishPostCodesUTM; var organizations; var allowedCountryCodes = ["NO","DK","SE","FI","LT"]; var formFields = [ + "weatherDataSourceType", + "latitude", + "longitude", + "timezone", "organizationId_countryCode", "weatherStationId", "dateSpraying1", @@ -380,13 +395,19 @@ var userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",formFields), false); if(!isDictEmpty(userSettings)) { renderUserSettings(userSettings); + if(theForm["weatherDataSourceType"].value == "grid") { + displayCoordinatesInput(); + } else if(theForm["weatherDataSourceType"].value == "weatherstation") { + displayWeatherstationInput(); + } else { + displayCoordinatesInput(); + } } else { updateGSDates(); } }); - }); }); -- GitLab