From d66020dcfd110104f8140244d18446b1e6282bac Mon Sep 17 00:00:00 2001 From: Lene Wasskog <lene.wasskog@nibio.no> Date: Fri, 25 Oct 2024 12:26:42 +0200 Subject: [PATCH] refactor: Rename to weatherDataSourceType --- .../formdefinitions/barleyNetBlotchForm.json | 5 +++++ .../cerealblotchmodels/barleynetblotchform.html | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cerealblotchmodels/static/cerealblotchmodels/formdefinitions/barleyNetBlotchForm.json b/cerealblotchmodels/static/cerealblotchmodels/formdefinitions/barleyNetBlotchForm.json index 0b84b056..eafca777 100755 --- a/cerealblotchmodels/static/cerealblotchmodels/formdefinitions/barleyNetBlotchForm.json +++ b/cerealblotchmodels/static/cerealblotchmodels/formdefinitions/barleyNetBlotchForm.json @@ -18,6 +18,11 @@ ], "_comment" : "Structure of the barleyNetBlotchForm and how to validate it", "fields": [ + { + "name" : "weatherDataSourceType", + "dataType" : "STRING", + "required" : true + }, { "name" : "latitude", "dataType" : "DOUBLE", diff --git a/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html b/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html index 7e22cc8d..4305be96 100755 --- a/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html +++ b/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html @@ -32,6 +32,7 @@ <link type="text/css" rel="stylesheet" href="https://logic.testvips.nibio.no/css/mapModal.css" /> <style> + /* Added when integrating map, should perhaps be moved to main css file. */ input#latitude, input#longitude { width: 30%; display: inline-block; @@ -76,7 +77,7 @@ <label class="main-label">Jeg vil bruke værdata</label> <div class="radio"> <label> - <input type="radio" name="weatherdataType" id="coordinates" value="coordinates" checked onchange="displayCoordinatesInput()"> + <input type="radio" name="weatherDataSourceType" id="grid" value="grid" checked onchange="displayCoordinatesInput()"> for et spesifikt punkt (koordinater) </label> <div id="input-coordinates"> @@ -88,7 +89,7 @@ </div> <div class="radio"> <label> - <input type="radio" name="weatherdataType" id="weatherstation" value="weatherstation" onchange="displayWeatherstationInput()"> + <input type="radio" name="weatherDataSourceType" id="weatherstation" value="weatherstation" onchange="displayWeatherstationInput()"> fra en værstasjon </label> <div id="input-weatherstation" style="display: none;"> @@ -298,8 +299,8 @@ window.validateFormExtra = () => { var theForm = document.getElementById("{{ form_id }}"); // Location: Either weatherStationId or latitude/longitude must be set - const selectedWeatherdataType = theForm.querySelector('input[name="weatherdataType"]:checked').value; - if( selectedWeatherdataType === "coordinates") { + const selectedWeatherdataType = theForm.querySelector('input[name="weatherDataSourceType"]:checked').value; + if( selectedWeatherdataType === "grid") { const trimmedLat = theForm["latitude"].value.trim() const trimmedLon = theForm["longitude"].value.trim() if(trimmedLat === "" || trimmedLon === "" || isNaN(Number(trimmedLat)) || isNaN(Number(trimmedLon))) { -- GitLab