fix toggle to show or hide appointments

This commit is contained in:
Julie Lenaerts 2022-05-17 16:05:00 +02:00
parent 0c61edd0d6
commit c0f9bf35ac
2 changed files with 14 additions and 9 deletions

View File

@ -94,7 +94,6 @@ import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
import timeGridPlugin from '@fullcalendar/timegrid';
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import { fetchCalendarRangesByUser, postCalendarRange } from '../_api/api';
import { mapGetters, mapActions, mapState } from 'vuex';
import { vShow } from 'vue';
@ -182,6 +181,7 @@ export default {
return `/fr/calendar/calendar/${this.myCalendarClickedEvent.id}/delete?user_id=${ this.userId }`
},
toggleMyCalendar(value) {
this.$store.commit('setAppointmentShown', value);
this.showMyCalendar = value;
},
toggleWeekends: function() {

View File

@ -1,7 +1,6 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
// import { deleteCalendarRange, fetchCalendar, fetchCalendarRangesByUser, patchCalendarRange, postCalendarRange } from '../_api/api';
const debug = process.env.NODE_ENV !== 'production';
@ -10,7 +9,7 @@ const store = createStore({
state: {
ranges: [],
appointments: [],
rangesToCopy: []
appointmentsShown: true
},
getters: {
rangeSource (state) {
@ -22,11 +21,15 @@ const store = createStore({
}
},
appointmentSource (state) {
return {
events: state.appointments,
color: "darkblue",
id: 1000,
editable: false
if (state.appointmentsShown) {
return {
events: state.appointments,
color: "darkblue",
id: 1000,
editable: false
}
} else {
return null
}
}
},
@ -48,6 +51,9 @@ const store = createStore({
},
setAppointments(state, payload) {
state.appointments = payload;
},
setAppointmentShown(state, payload) {
state.appointmentsShown = payload
}
},
actions: {
@ -58,7 +64,6 @@ const store = createStore({
.then((response) => {
if (payload) {
return response.results;
// commit('setRangesToCopy', response.results);
} else {
const ranges = response.results.map(range => (
{