rdv: add my calendar + checkbox

This commit is contained in:
nobohan
2021-08-19 10:52:47 +02:00
parent 7c4f976230
commit 0457ee2b8d
3 changed files with 36 additions and 17 deletions

View File

@@ -3,7 +3,9 @@
<calendar-user-selector
v-bind:users="users"
v-bind:calendarEvents="calendarEvents"
v-bind:updateEventsSource="updateEventsSource">
v-bind:updateEventsSource="updateEventsSource"
v-bind:showMyCalendar="showMyCalendar"
v-bind:toggleMyCalendar="toggleMyCalendar" >
</calendar-user-selector>
<h2 class="chill-red">{{ $t('choose_your_date') }}</h2>
<FullCalendar ref="fullCalendar" :options="calendarOptions">
@@ -51,15 +53,16 @@ export default {
calendarEvents: {
loaded: [],
selected: [],
user: [], //TODO load user calendar events
user: [],
current: currentEvent
},
showMyCalendar: true,
calendarOptions: {
locale: frLocale,
plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin ],
initialView: 'timeGridWeek',
initialDate: window.startDate !== undefined ? window.startDate : new Date(),
eventSources: window.startDate !== undefined ? [currentEvent] : [],
eventSource: [],
selectable: true,
select: this.onDateSelect,
eventChange: this.onEventChange,
@@ -79,19 +82,21 @@ export default {
methods: {
init() {
console.log(window.startDate)
// let calendar = this.$refs.fullCalendar.getApi()
// console.log(calendar)
this.calendarEvents.selected.push(this.calendarEvents.user);
this.calendarOptions.eventSources = this.calendarEvents.selected;
console.log(this.calendarOptions.eventSources)
this.updateEventsSource()
},
toggleMyCalendar(value) {
this.showMyCalendar = value;
},
updateEventsSource() {
this.calendarOptions.eventSources = [];
this.calendarOptions.eventSources.push(...this.calendarEvents.selected);
console.log(this.calendarOptions.eventSources)
if (window.startDate !== undefined) {
this.calendarEvents.selected.push(currentEvent);
this.calendarOptions.eventSources.push(currentEvent);
}
if (this.showMyCalendar) {
this.calendarOptions.eventSources.push(this.calendarEvents.user);
}
this.calendarEvents.selected.push(this.calendarEvents.user);
this.calendarOptions.eventSources = this.calendarEvents.selected;
console.log(this.calendarOptions.eventSources)
},
onDateSelect(payload) {