Observation search parameters now persist in session.

This commit is contained in:
neviyn 2018-11-14 10:32:16 +00:00
parent 3211a5af50
commit a1724d2437
3 changed files with 133 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import Vue from "vue"; import Vue from "vue";
import Vuex from "vuex"; import Vuex from "vuex";
var moment = require("moment");
Vue.use(Vuex); Vue.use(Vuex);
@ -9,7 +10,15 @@ export default new Vuex.Store({
tutors: [], tutors: [],
description: null, description: null,
type: null, type: null,
whom: null whom: null,
search: {
site: null,
tutor: null,
whom: null,
person: null,
start: moment().subtract(7, "days"),
end: moment()
}
}, },
mutations: { mutations: {
setSite(state, newSite) { setSite(state, newSite) {
@ -26,6 +35,24 @@ export default new Vuex.Store({
}, },
setWhom(state, newWhom) { setWhom(state, newWhom) {
state.whom = newWhom; state.whom = newWhom;
},
setSearchSite(state, data) {
state.search.site = data;
},
setSearchTutor(state, data) {
state.search.tutor = data;
},
setSearchWhom(state, data) {
state.search.whom = data;
},
setSearchPerson(state, data) {
state.search.person = data;
},
setSearchStartDate(state, data) {
state.search.start = data;
},
setSearchEndDate(state, data) {
state.search.end = data;
} }
}, },
actions: {} actions: {}

View File

@ -112,20 +112,64 @@ export default {
}, },
errorStatus: null, errorStatus: null,
errorMessage: null, errorMessage: null,
startDate: moment().subtract(7, "days"),
endDate: moment(),
dateOptions: { dateOptions: {
format: "DD/MM/YYYY", format: "DD/MM/YYYY",
useCurrent: false useCurrent: false
}, },
siteSelection: null,
siteOptions: [], siteOptions: [],
tutorSelection: null, tutorOptions: []
tutorOptions: [],
whom: null,
person: null
}; };
}, },
computed: {
startDate: {
get(){
return this.$store.state.search.start;
},
set(data){
this.$store.commit('setSearchStartDate', data);
}
},
endDate: {
get(){
return this.$store.state.search.end;
},
set(data){
this.$store.commit('setSearchEndDate', data);
}
},
siteSelection: {
get(){
return this.$store.state.search.site;
},
set(data){
this.$store.commit('setSearchSite', data);
}
},
tutorSelection: {
get(){
return this.$store.state.search.tutor;
},
set(data){
this.$store.commit('setSearchTutor', data)
}
},
whom: {
get(){
return this.$store.state.search.whom;
},
set(data){
this.$store.commit('setSearchWhom', data)
}
},
person: {
get(){
return this.$store.state.search.person;
},
set(data){
this.$store.commit('setSearchPerson', data)
}
}
},
methods: { methods: {
getFilteredAverage: function() { getFilteredAverage: function() {
Vue.axios Vue.axios
@ -187,6 +231,8 @@ export default {
this.errorMessage = error.response.data; this.errorMessage = error.response.data;
this.$refs.errorModal.show(); this.$refs.errorModal.show();
}); });
this.getTutors();
this.getFilteredAverage();
} }
}; };
</script> </script>

View File

@ -136,18 +136,12 @@ export default {
title: "Observations History", title: "Observations History",
data: function() { data: function() {
return { return {
startDate: moment().subtract(7, "days"),
endDate: moment(),
dateOptions: { dateOptions: {
format: "DD/MM/YYYY", format: "DD/MM/YYYY",
useCurrent: false useCurrent: false
}, },
siteSelection: null,
siteOptions: [], siteOptions: [],
tutorSelection: null,
tutorOptions: [], tutorOptions: [],
whom: null,
person: null,
observationData: null, observationData: null,
errorStatus: null, errorStatus: null,
errorMessage: null errorMessage: null
@ -166,6 +160,58 @@ export default {
} }
console.log(error); console.log(error);
}); });
this.getTutors();
this.getFiltered();
},
computed: {
startDate: {
get(){
return this.$store.state.search.start;
},
set(data){
this.$store.commit('setSearchStartDate', data);
}
},
endDate: {
get(){
return this.$store.state.search.end;
},
set(data){
this.$store.commit('setSearchEndDate', data);
}
},
siteSelection: {
get(){
return this.$store.state.search.site;
},
set(data){
this.$store.commit('setSearchSite', data);
}
},
tutorSelection: {
get(){
return this.$store.state.search.tutor;
},
set(data){
this.$store.commit('setSearchTutor', data)
}
},
whom: {
get(){
return this.$store.state.search.whom;
},
set(data){
this.$store.commit('setSearchWhom', data)
}
},
person: {
get(){
return this.$store.state.search.person;
},
set(data){
this.$store.commit('setSearchPerson', data)
}
}
}, },
methods: { methods: {
getFiltered: function() { getFiltered: function() {