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 @@
<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();
}
});
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment