mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: fullcalendar: select and unselect user calendars
This commit is contained in:
parent
e6deb6bc7a
commit
b40c25595a
@ -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);
|
||||
|
@ -13,7 +13,8 @@
|
||||
:close-on-select="false"
|
||||
:allow-empty="true"
|
||||
:model-value="value"
|
||||
@update:model-value="selectUsers"
|
||||
@select="selectUsers"
|
||||
@remove="unSelectUsers"
|
||||
:options="options">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
@ -64,10 +65,10 @@ export default {
|
||||
end: i.endDate.datetime
|
||||
})
|
||||
);
|
||||
console.log(arr);
|
||||
calendarEvents.push({
|
||||
events: arr,
|
||||
color: u.color
|
||||
color: u.color,
|
||||
id: u.id
|
||||
})
|
||||
})
|
||||
|
||||
@ -78,21 +79,6 @@ export default {
|
||||
console.log(calendarEvents)
|
||||
this.calendarEvents.loaded = calendarEvents;
|
||||
|
||||
// // TO TEST
|
||||
// this.calendarEvents.loaded = [{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!
|
||||
// }];
|
||||
|
||||
resolve()
|
||||
}))
|
||||
.catch((error) => {
|
||||
@ -102,8 +88,18 @@ export default {
|
||||
transName(value) {
|
||||
return `${value.username}`;
|
||||
},
|
||||
selectEvents() {
|
||||
let selectedUsersId = this.users.selected.map(a => a.id);
|
||||
this.calendarEvents.selected = this.calendarEvents.loaded.filter(a => selectedUsersId.includes(a.id));
|
||||
},
|
||||
selectUsers(value) {
|
||||
this.users.selected = value;
|
||||
this.users.selected.push(value);
|
||||
this.selectEvents();
|
||||
this.updateEventsSource();
|
||||
},
|
||||
unSelectUsers(value) {
|
||||
this.users.selected = this.users.selected.filter(a => a.id != value.id);
|
||||
this.selectEvents();
|
||||
this.updateEventsSource();
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user