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 Vuex from "vuex";
var moment = require("moment");
Vue.use(Vuex);
@ -9,7 +10,15 @@ export default new Vuex.Store({
tutors: [],
description: null,
type: null,
whom: null
whom: null,
search: {
site: null,
tutor: null,
whom: null,
person: null,
start: moment().subtract(7, "days"),
end: moment()
}
},
mutations: {
setSite(state, newSite) {
@ -26,6 +35,24 @@ export default new Vuex.Store({
},
setWhom(state, 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: {}

View File

@ -112,20 +112,64 @@ export default {
},
errorStatus: null,
errorMessage: null,
startDate: moment().subtract(7, "days"),
endDate: moment(),
dateOptions: {
format: "DD/MM/YYYY",
useCurrent: false
},
siteSelection: null,
siteOptions: [],
tutorSelection: null,
tutorOptions: [],
whom: null,
person: null
tutorOptions: []
};
},
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: {
getFilteredAverage: function() {
Vue.axios
@ -187,6 +231,8 @@ export default {
this.errorMessage = error.response.data;
this.$refs.errorModal.show();
});
this.getTutors();
this.getFilteredAverage();
}
};
</script>

View File

@ -136,18 +136,12 @@ export default {
title: "Observations History",
data: function() {
return {
startDate: moment().subtract(7, "days"),
endDate: moment(),
dateOptions: {
format: "DD/MM/YYYY",
useCurrent: false
},
siteSelection: null,
siteOptions: [],
tutorSelection: null,
tutorOptions: [],
whom: null,
person: null,
observationData: null,
errorStatus: null,
errorMessage: null
@ -166,6 +160,58 @@ export default {
}
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: {
getFiltered: function() {