diff --git a/frontend/src/store.js b/frontend/src/store.js index da600e2..1de1ae6 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -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: {} diff --git a/frontend/src/views/Stats.vue b/frontend/src/views/Stats.vue index 9c0d634..9c957cf 100644 --- a/frontend/src/views/Stats.vue +++ b/frontend/src/views/Stats.vue @@ -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(); } }; diff --git a/frontend/src/views/ViewObservations.vue b/frontend/src/views/ViewObservations.vue index 2790c31..f1d6f15 100644 --- a/frontend/src/views/ViewObservations.vue +++ b/frontend/src/views/ViewObservations.vue @@ -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() {