Skip to content
Snippets Groups Projects
Commit 6acfcad8 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Merge branch 'bugfix/vipsutv-706-observation-without-poi' into 'develop'

fix(observations): Ensure that pois of all relevant types are displayed in form

See merge request !181
parents 36124846 7c475445
Branches
No related tags found
1 merge request!181fix(observations): Ensure that pois of all relevant types are displayed in form
...@@ -308,6 +308,8 @@ fieldSowingDate = Field sowing date ...@@ -308,6 +308,8 @@ fieldSowingDate = Field sowing date
fields = Fields fields = Fields
traps = Traps
filter = Filter filter = Filter
filterList = Filter list filterList = Filter list
......
...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date ...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date
fields = Fields fields = Fields
traps = Traps
filter = Filter filter = Filter
filterList = Filter list filterList = Filter list
......
...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date ...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date
fields = Fields fields = Fields
traps = Traps
filter = Filter filter = Filter
filterList = Filter list filterList = Filter list
......
...@@ -308,6 +308,8 @@ fieldSowingDate = S\u00e5dato for felt ...@@ -308,6 +308,8 @@ fieldSowingDate = S\u00e5dato for felt
fields = Felt fields = Felt
traps = Feller
filter = Filter filter = Filter
filterList = Filtr\u00e9r lista filterList = Filtr\u00e9r lista
......
...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date ...@@ -306,6 +306,8 @@ fieldSowingDate = Field sowing date
fields = Fields fields = Fields
traps = Traps
filter = Filter filter = Filter
filterList = Filter list filterList = Filter list
......
...@@ -304,6 +304,8 @@ fieldSowingDate = Field sowing date ...@@ -304,6 +304,8 @@ fieldSowingDate = Field sowing date
fields = Fields fields = Fields
traps = Traps
filter = \u8fc7\u6ee4\u5668 filter = \u8fc7\u6ee4\u5668
filterList = Filter list filterList = Filter list
......
...@@ -230,38 +230,41 @@ ...@@ -230,38 +230,41 @@
var allPois = []; var allPois = [];
/** /**
* Fetches locations, farms, fields and weather stations, renders the list * Fetches locations, farms, fields, traps and weather stations, renders the list
*/ */
function refreshLocationPointOfInterests(pointOfInterestId) function refreshLocationPointOfInterests(selectedPointOfInterestId)
{ {
var poiTypes = ["${i18nBundle.genericPlaces}","${i18nBundle.weatherStations}","${i18nBundle.farms}","${i18nBundle.fields}"]; const poiTypes = {
$.getJSON("/rest/poi/user", function( json ) { 0: "${i18nBundle.genericPlaces}",
allPois = json; 1: "${i18nBundle.weatherStations}",
var theList = document.getElementById("locationPointOfInterestId"); 2: "${i18nBundle.farms}",
theList.options.length = 1; 3: "${i18nBundle.fields}",
// Locations first, weather stations next 5: "${i18nBundle.traps}"
for(var h=0;h<poiTypes.length;h++) };
{ $.getJSON("/rest/poi/user", function(json) {
var option = new Option("-- " + poiTypes[h] + " --","-1"); const allPois = json;
theList.options[theList.options.length] = option; const poiListElement = document.getElementById("locationPointOfInterestId");
for(var i=0;i< allPois.length;i++) poiListElement.options.length = 1;
{ // Iterate through each point of interest type
var poi = allPois[i]; for (const [typeId, typeName] of Object.entries(poiTypes)) {
if(poi.pointOfInterestTypeId == h) poiListElement.options[poiListElement.options.length] = new Option("-- " + typeName + " --", "-1");
{
var option = new Option(poi.name, poi.pointOfInterestId); // Iterate through all POIs and add them to the list if they match the type
if(poi.pointOfInterestId == pointOfInterestId) for (let i = 0; i < allPois.length; i++) {
{ const poi = allPois[i];
option.selected=true;
} if (poi.pointOfInterestTypeId == typeId) {
theList.options[theList.options.length] = option; const poiOption = new Option(poi.name, poi.pointOfInterestId);
} if (poi.pointOfInterestId === selectedPointOfInterestId) {
} poiOption.selected = true;
}
showCorrectMap();
} }
); poiListElement.options[poiListElement.options.length] = poiOption;
}
}
}
showCorrectMap();
});
} }
...@@ -515,7 +518,7 @@ ...@@ -515,7 +518,7 @@
<input type="hidden" name="observationData" value=""/> <input type="hidden" name="observationData" value=""/>
<input type="hidden" name="observationId" value="${observation.observationId!"-1"}"/> <input type="hidden" name="observationId" value="${observation.observationId!"-1"}"/>
<!--button type="button" onclick="var theForm=document.getElementById('observationForm');theForm['geoInfo'].value=getFeatures();try{mw.save();theForm['observationData'].value=JSON.stringify(mw.toInspect);return validateForm(theForm) && validateGIS(theForm);}catch(e){console.log(e.message);console.log(e);return false;}">Test</button--> <!--button type="button" onclick="var theForm=document.getElementById('observationForm');theForm['geoInfo'].value=getFeatures();try{mw.save();theForm['observationData'].value=JSON.stringify(mw.toInspect);return validateForm(theForm) && validateGIS(theForm);}catch(e){console.log(e.message);console.log(e);return false;}">Test</button-->
<#if observation.user?has_content> <#if observation.user?has_content>
<div class="form-group"> <div class="form-group">
<label>${i18nBundle.observer}: ${observation.user.firstName} ${observation.user.lastName}</label> <label>${i18nBundle.observer}: ${observation.user.firstName} ${observation.user.lastName}</label>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment