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

feat: Include only personal pois in timeseries form

parent 1af62b5f
Branches
Tags
No related merge requests found
...@@ -225,8 +225,7 @@ public class ObservationTimeSeriesController extends HttpServlet { ...@@ -225,8 +225,7 @@ public class ObservationTimeSeriesController extends HttpServlet {
request.setAttribute("mapLayers", userBean.getMapLayerJSONForUser(user)); request.setAttribute("mapLayers", userBean.getMapLayerJSONForUser(user));
request.setAttribute("defaultMapCenter", user.getOrganizationId().getDefaultMapCenter()); request.setAttribute("defaultMapCenter", user.getOrganizationId().getDefaultMapCenter());
request.setAttribute("defaultMapZoom", user.getOrganizationId().getDefaultMapZoom()); request.setAttribute("defaultMapZoom", user.getOrganizationId().getDefaultMapZoom());
request.setAttribute("locationPointOfInterests", request.setAttribute("locationPointOfInterests", pointOfInterestBean.getPoisForUser(user));
pointOfInterestBean.getRelevantPointOfInterestsForUser(user));
request.setAttribute("locationVisibilityFormValue", request.setAttribute("locationVisibilityFormValue",
getLocationVisibilityFormValue(observationTimeSeries)); getLocationVisibilityFormValue(observationTimeSeries));
List<PolygonService> polygonServices = List<PolygonService> polygonServices =
......
...@@ -1103,4 +1103,5 @@ observationTimeSeriesStored = Observation time series was stored ...@@ -1103,4 +1103,5 @@ observationTimeSeriesStored = Observation time series was stored
noTimeSeries = No observation time series noTimeSeries = No observation time series
noObservations = No observations noObservations = No observations
noForecasts = No forecasts noForecasts = No forecasts
timeSeriesNoAvailablePoi=You must create a location before you can register a new time series
...@@ -1102,4 +1102,4 @@ observationTimeSeriesStored = Tidsserie lagret ...@@ -1102,4 +1102,4 @@ observationTimeSeriesStored = Tidsserie lagret
noTimeSeries = Ingen tidsserier noTimeSeries = Ingen tidsserier
noObservations = Ingen observasjoner noObservations = Ingen observasjoner
noForecasts = Ingen varsler noForecasts = Ingen varsler
timeSeriesNoAvailablePoi=Du m opprette et nytt sted fr du kan registrere tidsserie
...@@ -62,28 +62,32 @@ ...@@ -62,28 +62,32 @@
} }
fetchPOIs(function (allPois) { fetchPOIs(function (allPois) {
buildPOIList(poiListElement, allPois, poiTypes, selectedPointOfInterestId); buildPOIList(poiListElement, allPois, poiTypes, selectedPointOfInterestId, ${user.userId});
showCorrectMap(); showCorrectMap();
}); });
} }
function buildPOIList(poiListElement, allPois, poiTypes, selectedPointOfInterestId) { function buildPOIList(poiListElement, allPois, poiTypes, selectedPointOfInterestId, userId) {
poiListElement.options.length = 1; poiListElement.options.length = 1;
const userPois = allPois.filter(poi => String(poi.userId) === String(userId));
if(userPois.length === 0) {
document.getElementById("noAvailablePoi").style.display = "block";
} else {
document.getElementById("noAvailablePoi").style.display = "none";
}
for (const [typeId, typeName] of Object.entries(poiTypes)) { for (const [typeId, typeName] of Object.entries(poiTypes)) {
let poiTypeOption = new Option("-- " + typeName + " --", "-1"); const poisOfType = userPois.filter(poi => String(poi.pointOfInterestTypeId) === String(typeId));
if (poisOfType.length === 0) continue;
const poiTypeOption = new Option("-- " + typeName + " --", "");
poiTypeOption.disabled = true; poiTypeOption.disabled = true;
poiListElement.options[poiListElement.options.length] = poiTypeOption; poiListElement.options[poiListElement.options.length] = poiTypeOption;
for (let i = 0; i < allPois.length; i++) { for (const poi of poisOfType) {
const poi = allPois[i]; const poiOption = new Option(poi.name, poi.pointOfInterestId);
if (poi.pointOfInterestId === selectedPointOfInterestId) {
if (poi.pointOfInterestTypeId == typeId) { poiOption.selected = true;
const poiOption = new Option(poi.name, poi.pointOfInterestId);
if (poi.pointOfInterestId === selectedPointOfInterestId) {
poiOption.selected = true;
}
poiListElement.options[poiListElement.options.length] = poiOption;
} }
poiListElement.options[poiListElement.options.length] = poiOption;
} }
} }
} }
...@@ -315,6 +319,7 @@ ...@@ -315,6 +319,7 @@
<div id="errorMsgEl" class="alert alert-danger" <#if !formValidation?has_content> style="display:none;"</#if>> <div id="errorMsgEl" class="alert alert-danger" <#if !formValidation?has_content> style="display:none;"</#if>>
<#if formValidation?has_content>${formValidation.validationMessages?replace("\n", "<br>")}</#if> <#if formValidation?has_content>${formValidation.validationMessages?replace("\n", "<br>")}</#if>
</div> </div>
<div id="noAvailablePoi" class="alert alert-danger" style="display: none">Du må opprette et nytt sted før du kan registrere tidsserie</div>
<#if messageKey?has_content> <#if messageKey?has_content>
<div class="alert alert-success">${i18nBundle(messageKey)}</div> <div class="alert alert-success">${i18nBundle(messageKey)}</div>
</#if> </#if>
...@@ -430,10 +435,11 @@ ...@@ -430,10 +435,11 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="locationPointOfInterestId">${i18nBundle.location}&nbsp;&nbsp;<button <label for="locationPointOfInterestId">${i18nBundle.location}</label>&nbsp;
role="button" type="button" <button
onclick="addNewLocationPopup();">${i18nBundle.addNew}</button> role="button" type="button"
</label> onclick="addNewLocationPopup();">${i18nBundle.addNew}</button>
<select class="form-control" name="locationPointOfInterestId" id="locationPointOfInterestId" onchange="showCorrectMap();"> <select class="form-control" name="locationPointOfInterestId" id="locationPointOfInterestId" onchange="showCorrectMap();">
<option value="" disabled selected>${i18nBundle.pleaseSelect} ${i18nBundle.location?lower_case}</option> <option value="" disabled selected>${i18nBundle.pleaseSelect} ${i18nBundle.location?lower_case}</option>
</select> </select>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment