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

View File

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