rdv: fullcalendar vue: use store and add an event on date select

This commit is contained in:
nobohan 2021-07-21 13:59:31 +02:00
parent f508971b6a
commit 0585455bbe
2 changed files with 22 additions and 2 deletions

View File

@ -29,6 +29,7 @@ const store = createStore({
strict: debug,
state: {
activity: mapEntity(window.entity),
events: []
},
mutations: {
@ -60,6 +61,11 @@ const store = createStore({
state.activity.users = state.activity.users.filter(user => user !== payload);
break;
};
},
// Calendar
onDateSelect(state, payload) {
console.log(payload)
state.events.push( {start: payload.start, end: payload.end})
}
},
actions: {
@ -98,6 +104,12 @@ const store = createStore({
break;
};
commit('removePersonInvolved', payload);
},
// Calendar
onDateSelect({ commit }, payload) {
console.log('### action onDateSelect', payload);
commit('onDateSelect', payload);
}
}
});

View File

@ -1,4 +1,5 @@
<template>
<h2 class="chill-red">{{ $t('choose_your_date') }}</h2>
<FullCalendar :options="calendarOptions" />
</template>
<script>
@ -9,15 +10,22 @@ import interactionPlugin from '@fullcalendar/interaction'
export default {
components: {
FullCalendar // make the <FullCalendar> tag available
FullCalendar
},
data() {
return {
calendarOptions: {
plugins: [ dayGridPlugin, interactionPlugin ],
initialView: 'dayGridMonth'
initialView: 'dayGridMonth',
selectable: true,
select: this.onDateSelect
}
}
},
methods: {
onDateSelect(payload) {
this.$store.dispatch('onDateSelect', payload);
}
}
}
</script>