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

fix: Ensure observation data is stored and displayed for timeseries obs

parent a04d5f54
Branches
No related tags found
No related merge requests found
...@@ -662,6 +662,9 @@ var app = window.app; ...@@ -662,6 +662,9 @@ var app = window.app;
* @return {GEOJson} returns all features currently on the map in GEOJson format * @return {GEOJson} returns all features currently on the map in GEOJson format
*/ */
function getFeatures() { function getFeatures() {
if(!featureOverlay){
return null;
}
var features = featureOverlay.getSource().getFeatures(); var features = featureOverlay.getSource().getFeatures();
var format = new ol.format.GeoJSON(); var format = new ol.format.GeoJSON();
// write features to GeoJSON format using projection EPSG:4326 // write features to GeoJSON format using projection EPSG:4326
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
var organizationId = ${user.organizationId.organizationId}; var organizationId = ${user.organizationId.organizationId};
var selectedCropId = <#if observation.cropOrganism?has_content>${observation.cropOrganism.organismId?c}<#else>null</#if>; var selectedCropId = <#if observation.cropOrganism?has_content>${observation.cropOrganism.organismId?c}<#else>null</#if>;
$(document).ready(function () { $(document).ready(function () {
// Load main form definition (for validation) // Load main form definition (for validation)
...@@ -54,11 +53,9 @@ ...@@ -54,11 +53,9 @@
// If observation already registered center on location // If observation already registered center on location
// Otherwise, center and zoom to organizations's default // Otherwise, center and zoom to organizations's default
<#if observation.location?has_content> <#if observation.location?has_content>
initGisInfoMap([${(observation.location.x?c)!""}, ${(observation.location.y?c)!""}], 10, true); initGisInfoMap([${(observation.location.x?c)!""}, ${(observation.location.y?c)!""}], 10, true);
<#elseif !observation.observationTimeSeries?has_content> <#elseif !observation.observationTimeSeries?has_content>
var geoInfo = <#if observation.geoinfo?has_content>${observation.geoinfo}<#else> var geoInfo = <#if observation.geoinfo?has_content>${observation.geoinfo}<#else>{}
{
}
</#if>; </#if>;
var chooseFromMapLayers = {"chooseFromMapLayers": <#if mapLayers?has_content>${mapLayers}<#else>[]</#if>}; var chooseFromMapLayers = {"chooseFromMapLayers": <#if mapLayers?has_content>${mapLayers}<#else>[]</#if>};
initGisInfoMap("observationFormMap", [${defaultMapCenter.x?c}, ${defaultMapCenter.y?c}], ${defaultMapZoom}, false, geoInfo, chooseFromMapLayers); initGisInfoMap("observationFormMap", [${defaultMapCenter.x?c}, ${defaultMapCenter.y?c}], ${defaultMapZoom}, false, geoInfo, chooseFromMapLayers);
...@@ -71,8 +68,9 @@ ...@@ -71,8 +68,9 @@
observationData = ${observation.observationData}; observationData = ${observation.observationData};
getDataSchema(${observation.organism.organismId}, organizationId); getDataSchema(${observation.organism.organismId}, organizationId);
<#elseif observation.organism?has_content> <#elseif observation.organism?has_content>
// Setting
initObservationData(${observation.organism.organismId}, organizationId); initObservationData(${observation.organism.organismId}, organizationId);
<#elseif observation.observationTimeSeries?has_content>
initObservationData(${observation.observationTimeSeries.organismId}, organizationId);
</#if> </#if>
<#if observation.observationTimeSeries?has_content> <#if observation.observationTimeSeries?has_content>
displayObservationTimeSeriesInfo("${observation.observationTimeSeries.cropOrganismId}", "${observation.observationTimeSeries.organismId}", "${observation.observationTimeSeries.locationPointOfInterestId}") displayObservationTimeSeriesInfo("${observation.observationTimeSeries.cropOrganismId}", "${observation.observationTimeSeries.organismId}", "${observation.observationTimeSeries.locationPointOfInterestId}")
...@@ -139,7 +137,6 @@ ...@@ -139,7 +137,6 @@
document.getElementById("locationDisplayName").innerHTML = locationName || null; document.getElementById("locationDisplayName").innerHTML = locationName || null;
}); });
initLocationMap(locationPointOfInterestId); initLocationMap(locationPointOfInterestId);
initObservationData(organismId, organizationId);
} }
function getDataSchema(organismId, organizationId) { function getDataSchema(organismId, organizationId) {
...@@ -490,8 +487,6 @@ ...@@ -490,8 +487,6 @@
* Does all the ifs and buts before form can potentially be submitted * Does all the ifs and buts before form can potentially be submitted
*/ */
function prepareFormSubmit(theForm) { function prepareFormSubmit(theForm) {
// Extract GIS info from OpenLayers
theForm['geoInfo'].value = getFeatures();
try { try {
// If the form is quantified: Inspect the fields and write // If the form is quantified: Inspect the fields and write
// JSON string to the generic form field "observationData"; // JSON string to the generic form field "observationData";
...@@ -503,10 +498,15 @@ ...@@ -503,10 +498,15 @@
} }
theForm['observationData'].value = JSON.stringify(editor.getValue()); theForm['observationData'].value = JSON.stringify(editor.getValue());
} }
validateGIS(theForm); // Extract GIS info from OpenLayers
let theFeatures = getFeatures();
if (theFeatures) {
theForm['geoInfo'].value = theFeatures;
return validateForm(theForm) && validateGIS(theForm);
}
return validateForm(theForm);
//console.info('validateGIS = ' + (validateGIS(this))); //console.info('validateGIS = ' + (validateGIS(this)));
//return false; // DEBUG setting //return false; // DEBUG setting
return validateForm(theForm) && validateGIS(theForm); // PROD setting
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
console.log(e); console.log(e);
...@@ -519,7 +519,7 @@ ...@@ -519,7 +519,7 @@
<div class="singleBlockContainer"> <div class="singleBlockContainer">
<p><a href="${returnPath}" class="btn btn-default back" role="button">${i18nBundle.back}</a> <p><a href="${returnPath}" class="btn btn-default back" role="button">${i18nBundle.back}</a>
<#if observation.observationId?has_content><a <#if observation.observationId?has_content><a
href="/observation?action=newObservationForm" class="btn btn-default" href="/observation?action=newObservationForm<#if observation.observationTimeSeriesId?has_content>&observationTimeSeriesId=${observation.observationTimeSeriesId}</#if>" class="btn btn-default"
role="button">${i18nBundle.addNew}</a></#if></p> role="button">${i18nBundle.addNew}</a></#if></p>
<h1><#if observation.observationId?has_content>${i18nBundle.editObservation}<#else>${i18nBundle.newObservation}</#if><#if observation.observationTimeSeriesId?has_content> ${i18nBundle.forTimeSeries}</#if><#if shortcut?has_content> - ${shortcut.getLocalLabel(currentLocale.language)?lower_case}</#if></h1> <h1><#if observation.observationId?has_content>${i18nBundle.editObservation}<#else>${i18nBundle.newObservation}</#if><#if observation.observationTimeSeriesId?has_content> ${i18nBundle.forTimeSeries}</#if><#if shortcut?has_content> - ${shortcut.getLocalLabel(currentLocale.language)?lower_case}</#if></h1>
<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>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment