diff --git a/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html b/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html index dd0cd96ea7432b82b7c38623046f28c8101e3343..8d062db8617c3e0a0b1eb67fd5b61f65d73e9bc3 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(); } }); - }); });