Skip to content
Snippets Groups Projects
Commit b20bad82 authored by Bhabesh Bhabani Mukhopadhyay's avatar Bhabesh Bhabani Mukhopadhyay
Browse files

Retain data after back button

parent f1153234
No related branches found
No related tags found
No related merge requests found
<template>
<div>
<div id='map-observation'>
<div v-if="isMyMapPanelVisible"><router-link id='btnBack' :to="{name: 'Observation', params:{observationId:myObservationId, paramGeoinfo:myGeoInfo}}" class="btn btn-success ">Back</router-link></div>
<div v-if="isMyMapPanelVisible"><router-link id='btnBack' :to="{name: 'Observation', params:{observationId:myObservationId, paramGeoinfo:myGeoInfo, paramObservation:mapObservation}}" class="btn btn-success ">Back</router-link></div>
<div v-if="isMyMapPanelVisible" id='map-mylocation'>
<button class="border border-primary rounded-circle" v-on:click="myposition"><i class='fas fa-crosshairs'></i></button>
</div>
......@@ -71,7 +71,7 @@ let parser = new WMTSCapabilities();
export default {
name : 'MapObservation',
props : ['observationId','geoinfo','isMapPanelVisible','locationPointOfInterestId','locationIsPrivate','polygonService'],
props : ['observationId','geoinfo','isMapPanelVisible','locationPointOfInterestId','locationIsPrivate','polygonService','observation'],
components : {CommonUtil,Visibility},
data(){
return {
......@@ -86,6 +86,7 @@ export default {
poi : {pointOfInterestId:'undefined',name:'Select POI'},
myMap : '',
myObservationId : '',
mapObservation : {},
}
},
methods : {
......@@ -449,6 +450,11 @@ export default {
var panelObDiv = document.getElementById("ObservationMapPanel");
var divPrivacy = document.getElementById("divPrivacy");
if(routeParam.observation)
{
this.mapObservation = routeParam.observation;
}
if(routeParam.observationId)
{
this.myObservationId = routeParam.observationId;
......
......@@ -16,15 +16,17 @@
<div class="clearfix"/>
<div ref='divDateTime'>
<!-- <input type="datetime-local" v-bind='strDateObservation | dateFormat' v-model="strDateObservation"/> -->
<input type="datetime-local" v-model="strDateObservation" />
<input type="datetime-local" v-model="strDateObservation" v-on:change="capturedTime($event)"/>
</div>
<div v-if="isMounted">
<router-link id="linkMap" ref='linkMap' :to="{name:'MapObservation', params: {observationId:observation.observationId,geoinfo:mapGeoinfo,isMapPanelVisible:newMapPanel,locationPointOfInterestId:mapLocationPointOfInterestId, observation:observation}}">Observation Map </router-link>
</div>
<router-link id="linkMap" ref='linkMap' :to="{name:'MapObservation', params: {observationId:observationId,geoinfo:mapGeoinfo,isMapPanelVisible:newMapPanel,locationPointOfInterestId:mapLocationPointOfInterestId}}">Observation Map </router-link>
<div v-if="mapGeoinfo" id="divMapGeoInfo"><div v-if="isMounted"><map-observation :geoinfo="mapGeoinfo" :isMapPanelVisible="isMapPanelVisible" :locationIsPrivate="observation.locationIsPrivate" :polygonService="observation.polygonService" v-on:visibilityObservationAction="visibilityObservationAction" ></map-observation></div></div>
<photo :isImageVisible=false :observationId="observationId" :organismId="observation.organismId" ></photo>
<photo :isImageVisible=true :observationId="observation.observationId" :organismId="observation.organismId" :imageFileName="photo.observationIllustrationPK.fileName" :isDeleted='photo.deleted' v-for="photo in observation.observationIllustrationSet" v-bind:key="photo.observationIllustrationPK.fileName"></photo>
<div v-if="isMounted">
<photo :isImageVisible=false :observationId="observationId" :organismId="observation.organismId" ></photo>
<photo :isImageVisible=true :observationId="observation.observationId" :organismId="observation.organismId" :imageFileName="photo.observationIllustrationPK.fileName" :isDeleted='photo.deleted' v-for="photo in observation.observationIllustrationSet" v-bind:key="photo.observationIllustrationPK.fileName"></photo>
<!-- <photo-observation :observationId="observation.observationId" :organismId="observation.organismId" :imageFileName="photo.observationIllustrationPK.fileName" v-for="photo in observation.observationIllustrationSet" v-bind:key="photo.observationIllustrationPK.fileName"></photo-observation> -->
</div>
<div class="clearfix"/>
<button class="btn btn-success" v-on:click="showQuantification"><span><h5>Tell/kvantifiser</h5></span></button>
......@@ -59,7 +61,7 @@ import Quantification from '@/components/Quantification.vue'
export default {
name: 'Observation',
props: ['observationId','paramGeoinfo'],
props: ['observationId','paramGeoinfo','paramObservation'],
components: {MapObservation,PhotoObservation,Photo,Quantification},
data () {
return {
......@@ -122,8 +124,7 @@ export default {
let jsonObservation = {};
let lstObservations = JSON.parse(localStorage.getItem(CommonUtil.CONST_STORAGE_OBSERVATION_LIST)); // Observation List
jsonObservation = lstObservations.find(({observationId})=> observationId === id); // Selection Observation
this.observation = jsonObservation;
/*
let lastQuoteRemoved = this.observation.observationData.slice(0,0);
......@@ -131,15 +132,30 @@ export default {
this.observation.observationData = lastQuoteRemoved.slice(0,0);
console.log(this.observation.observationData);
*/
/* For related Crop and Crop list */
this.getObservationCrops(jsonObservation);
/* For related Pest and Pest list */
this.getObservationPests(jsonObservation);
if(this.paramObservation)
{
this.getObservationCrops(this.paramObservation);
this.getObservationPests(this.paramObservation);
this.strDateObservation = DateTime.fromISO(this.paramObservation.timeOfObservation).toFormat('yyyy-MM-dd\'T\'HH:mm:ss');
}
else
{
jsonObservation = lstObservations.find(({observationId})=> observationId === id); // Selection Observation
this.observation = jsonObservation;
this.strDateObservation = DateTime.fromISO(jsonObservation.timeOfObservation).toFormat('yyyy-MM-dd\'T\'HH:mm:ss');
/* For related Crop and Crop list */
this.getObservationCrops(jsonObservation);
/* For related Pest and Pest list */
this.getObservationPests(jsonObservation);
this.strDateObservation = DateTime.fromISO(jsonObservation.timeOfObservation).toFormat('yyyy-MM-dd\'T\'HH:mm:ss');
this.observationHeader = jsonObservation.observationHeading;
this.observationText = jsonObservation.observationText;
}
this.observationHeader = jsonObservation.observationHeading;
this.observationText = jsonObservation.observationText;
if(this.paramGeoinfo)
{
......@@ -166,6 +182,7 @@ export default {
/** Get related crop and crop list for a selected Observation */
getObservationCrops(jsonObservation){
let lstCrops = [];
let lstCropIds = [];
let lstCropList = JSON.parse(localStorage.getItem(CommonUtil.CONST_STORAGE_CROP_LIST));
......@@ -185,7 +202,7 @@ export default {
this.isActive = true;
// iterate and get the required cropids relaed to selected observation id
$.each (data, function(index, item){
if(item===jsonObservation.cropOrganismId)
if(parseInt(item)===parseInt(jsonObservation.cropOrganismId))
{
lstCropIds = data;
return false;
......@@ -194,11 +211,10 @@ export default {
}
})
});
/* Get list of related crops with their id and name */
this.getCrops(lstCropIds);
let jsonSelectedCrop= this.crops.find(({organismId}) => organismId === jsonObservation.cropOrganismId);
let jsonSelectedCrop= this.crops.find(({organismId}) => organismId === parseInt(jsonObservation.cropOrganismId));
// this.crops = lstCrops;
if(jsonSelectedCrop)
{
......@@ -214,13 +230,12 @@ export default {
let lstCropPestList = JSON.parse(localStorage.getItem(CommonUtil.CONST_STORAGE_CROP_PEST_LIST));
$.each(lstCropPestList, function(index,cropPests){
if(cropPests.cropOrganismId === jsonObservation.cropOrganismId)
if(parseInt(cropPests.cropOrganismId) === parseInt(jsonObservation.cropOrganismId))
{
lstPestIds = cropPests.pestOrganismIds;
}
});
this.getPests(lstPestIds);
let jsonSelectedPest = this.pests.find(({pestId}) => pestId === jsonObservation.organismId);
......@@ -235,6 +250,7 @@ export default {
/** On selecting a particular crop */
selectCrop(event)
{
this.observation.cropOrganismId=event.target.value;
let crop = this.crop;
let lstPestIds = [];
let lstCropPestList = JSON.parse(localStorage.getItem(CommonUtil.CONST_STORAGE_CROP_PEST_LIST));
......@@ -251,6 +267,11 @@ export default {
},
capturedTime(event)
{
this.observation.timeOfObservation=this.strDateObservation;
},
/** Get New Observation */
getNewObservation()
......@@ -443,8 +464,11 @@ export default {
} ,
mounted(){
if(this.paramObservation)
{
this.observation = this.paramObservation;
}
if(this.paramGeoinfo)
{
this.mapGeoinfo = this.paramGeoinfo;
......@@ -455,7 +479,7 @@ export default {
if(this.observationId)
{
this.getObservationFromStore(this.observationId);
this.observation.observationId=this.observationId
this.observation.observationId=this.observationId;
}
else{
let newObservationId = 0;
......@@ -465,8 +489,11 @@ export default {
this.observation.observationData='';
this.getNewObservation();
}
this.observationForStore.locationIsPrivate=this.observation.locationIsPrivate;
this.observationForStore.polygonService=this.observation.polygonService;
if(!this.paramObservation)
{
this.observationForStore.locationIsPrivate=this.observation.locationIsPrivate;
this.observationForStore.polygonService=this.observation.polygonService;
}
},
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment