Skip to content
Snippets Groups Projects
Commit 8780c578 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Remember settings in septoriahumidity

parent 2fb71a79
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<div class="form-group"> <div class="form-group">
<div class="radio"> <div class="radio">
<label> <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 for et punkt i kartet
</label> </label>
<div id="input-coordinates"> <div id="input-coordinates">
...@@ -255,10 +255,9 @@ ...@@ -255,10 +255,9 @@
const selectedLongitude = coordinatesData ? coordinatesData.longitude : undefined; const selectedLongitude = coordinatesData ? coordinatesData.longitude : undefined;
if(selectedLatitude && selectedLongitude) { if(selectedLatitude && selectedLongitude) {
console.error("Coordinates selected!")
inputLatitudeElement.value = selectedLatitude; inputLatitudeElement.value = selectedLatitude;
inputLongitudeElement.value = selectedLongitude; inputLongitudeElement.value = selectedLongitude;
getTimezone(selectedLatitude, selectedLongitude); getTimezoneForPoint(selectedLatitude, selectedLongitude);
} }
} }
...@@ -274,6 +273,7 @@ ...@@ -274,6 +273,7 @@
window.openCoordinatesMap = () => { window.openCoordinatesMap = () => {
if (inputLatitudeElement.value && inputLongitudeElement.value) { if (inputLatitudeElement.value && inputLongitudeElement.value) {
console.info(`Open map for lat=${parseFloat(inputLatitudeElement.value)} lon=${parseFloat(inputLatitudeElement.value)}`)
selectedPoint = 1; selectedPoint = 1;
selectedFeature = { selectedFeature = {
"type": "FeatureCollection", "features": [ "type": "FeatureCollection", "features": [
...@@ -331,9 +331,10 @@ ...@@ -331,9 +331,10 @@
document.getElementById("grid").checked = true; document.getElementById("grid").checked = true;
document.getElementById('input-weatherstation').style.display="none"; document.getElementById('input-weatherstation').style.display="none";
document.getElementById('input-coordinates').style.display="block"; document.getElementById('input-coordinates').style.display="block";
getTimezoneForSelectedPoint()
} }
const getTimezone = (latitude, longitude) => { const getTimezoneForPoint = (latitude, longitude) => {
getLocationInformation(latitude, longitude).then(locationInfo => { getLocationInformation(latitude, longitude).then(locationInfo => {
theForm["timezone"].value = locationInfo.timezone; theForm["timezone"].value = locationInfo.timezone;
document.getElementById("gridPointInfo").innerHTML = `<b>Sted</b> ${locationInfo.location}<br> document.getElementById("gridPointInfo").innerHTML = `<b>Sted</b> ${locationInfo.location}<br>
...@@ -343,10 +344,24 @@ ...@@ -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 danishPostCodesUTM;
var organizations; var organizations;
var allowedCountryCodes = ["NO","DK","SE","FI","LT"]; var allowedCountryCodes = ["NO","DK","SE","FI","LT"];
var formFields = [ var formFields = [
"weatherDataSourceType",
"latitude",
"longitude",
"timezone",
"organizationId_countryCode", "organizationId_countryCode",
"weatherStationId", "weatherStationId",
"dateSpraying1", "dateSpraying1",
...@@ -380,13 +395,19 @@ ...@@ -380,13 +395,19 @@
var userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",formFields), false); var userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",formFields), false);
if(!isDictEmpty(userSettings)) { if(!isDictEmpty(userSettings)) {
renderUserSettings(userSettings); renderUserSettings(userSettings);
if(theForm["weatherDataSourceType"].value == "grid") {
displayCoordinatesInput();
} else if(theForm["weatherDataSourceType"].value == "weatherstation") {
displayWeatherstationInput();
} else {
displayCoordinatesInput();
}
} }
else else
{ {
updateGSDates(); updateGSDates();
} }
}); });
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment