mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
rdv: fullcalendar: select and unselect user calendars
This commit is contained in:
@@ -22,6 +22,15 @@ import dayGridPlugin from '@fullcalendar/daygrid'
|
||||
import interactionPlugin from '@fullcalendar/interaction'
|
||||
import timeGridPlugin from '@fullcalendar/timegrid'
|
||||
|
||||
const currentEvent = {
|
||||
events: [{
|
||||
title: 'my_event',
|
||||
start: window.startDate,
|
||||
end: window.endDate
|
||||
}],
|
||||
id: -1
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
components: {
|
||||
@@ -38,39 +47,20 @@ export default {
|
||||
},
|
||||
calendarEvents: {
|
||||
loaded: [],
|
||||
selected: []
|
||||
selected: [],
|
||||
userEvents: [], //TODO load user calendar events
|
||||
current: currentEvent
|
||||
},
|
||||
calendarOptions: {
|
||||
plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin ],
|
||||
initialView: 'timeGridWeek',
|
||||
initialEvents: window.startDate !== undefined ?
|
||||
[
|
||||
{
|
||||
id: 1,
|
||||
start: window.startDate,
|
||||
end: window.endDate
|
||||
}
|
||||
] : [],
|
||||
initialDate: window.startDate !== undefined ? window.startDate : new Date(),
|
||||
// eventSources: [{events: [
|
||||
// {
|
||||
// title: 'Event1',
|
||||
// start: '2021-08-04T12:30:00'
|
||||
// },
|
||||
// {
|
||||
// title: 'Event2',
|
||||
// start: '2021-08-05T12:30:00'
|
||||
// }
|
||||
// ],
|
||||
// color: 'yellow', // an option!
|
||||
// textColor: 'black' // an option!
|
||||
// }],//this work at initialisation, initialize with initialEvents content?
|
||||
eventSources: window.startDate !== undefined ? [currentEvent] : [],
|
||||
selectable: true,
|
||||
select: this.onDateSelect,
|
||||
eventChange: this.onEventChange,
|
||||
selectMirror: true,
|
||||
editable: true,
|
||||
lazyFetching: false, // To fetch at maximum
|
||||
headerToolbar: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
@@ -82,25 +72,17 @@ export default {
|
||||
methods: {
|
||||
init() {
|
||||
console.log(window.startDate)
|
||||
let calendar = this.$refs.fullCalendar.getApi()
|
||||
//calendar.next()
|
||||
console.log(calendar)
|
||||
// let calendar = this.$refs.fullCalendar.getApi()
|
||||
// console.log(calendar)
|
||||
},
|
||||
updateEventsSource() {
|
||||
console.log('updateEventsSource')
|
||||
|
||||
console.log(this.calendarEvents.loaded);
|
||||
this.calendarEvents.selected = this.calendarEvents.loaded; //TODO filter loaded events on selected users
|
||||
|
||||
// this works!!!
|
||||
console.log(this.calendarEvents.selected)
|
||||
|
||||
this.calendarOptions.eventSources = this.calendarEvents.selected;
|
||||
|
||||
// let calendar = this.$refs.fullCalendar.getApi();
|
||||
// console.log(calendar);
|
||||
// console.log(calendar.getEventSources())
|
||||
// calendar.addEventSource(this.calendarEvents.selected);
|
||||
|
||||
// console.log(calendar.getEventSources())
|
||||
if (window.startDate !== undefined) {
|
||||
this.calendarEvents.selected.push(currentEvent);
|
||||
}
|
||||
},
|
||||
onDateSelect(payload) {
|
||||
this.$store.dispatch('createEvent', payload);
|
||||
|
Reference in New Issue
Block a user