rdv: various UI improvements to the calendar

This commit is contained in:
nobohan 2021-08-20 16:14:51 +02:00
parent 6a6b1760f5
commit de8478f3e5
5 changed files with 33 additions and 17 deletions

View File

@ -87,7 +87,8 @@ class CalendarController extends AbstractController
// $view = 'ChillCalendarBundle:Calendar:listByUser.html.twig'; // $view = 'ChillCalendarBundle:Calendar:listByUser.html.twig';
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
$calendarItems = $em->getRepository(Calendar::class)->findBy( $calendarItems = $em->getRepository(Calendar::class)->findBy(
['accompanyingPeriod' => $accompanyingPeriod] ['accompanyingPeriod' => $accompanyingPeriod],
['startDate' => 'DESC']
); );
$view = 'ChillCalendarBundle:Calendar:listByAccompanyingCourse.html.twig'; $view = 'ChillCalendarBundle:Calendar:listByAccompanyingCourse.html.twig';

View File

@ -6,13 +6,15 @@
v-bind:calendarEvents="calendarEvents" v-bind:calendarEvents="calendarEvents"
v-bind:updateEventsSource="updateEventsSource" v-bind:updateEventsSource="updateEventsSource"
v-bind:showMyCalendar="showMyCalendar" v-bind:showMyCalendar="showMyCalendar"
v-bind:toggleMyCalendar="toggleMyCalendar" > v-bind:toggleMyCalendar="toggleMyCalendar"
v-bind:toggleWeekends="toggleWeekends" >
</calendar-user-selector> </calendar-user-selector>
</teleport> </teleport>
<teleport to="#fullCalendar"> <teleport to="#fullCalendar">
<FullCalendar ref="fullCalendar" :options="calendarOptions"> <FullCalendar ref="fullCalendar" :options="calendarOptions">
<template v-slot:eventContent='arg'> <template v-slot:eventContent='arg'>
<b>{{ arg.timeText }}</b> <b>{{ arg.timeText }}</b>
<i>&nbsp;{{ arg.event.title }}</i>
</template> </template>
</FullCalendar> </FullCalendar>
</teleport> </teleport>
@ -27,7 +29,7 @@ import FullCalendar from '@fullcalendar/vue3';
import dayGridPlugin from '@fullcalendar/daygrid'; 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 listPlugin from '@fullcalendar/list'; // import listPlugin from '@fullcalendar/list';
export default { export default {
name: "App", name: "App",
@ -50,11 +52,12 @@ export default {
user: [], user: [],
current: { current: {
events: [{ events: [{
title: 'my_event', title: 'plage prévue',
start: window.startDate, start: window.startDate,
end: window.endDate end: window.endDate
}], }],
id: window.mainUser id: window.mainUser,
color: '#bbbbbb'
} }
}, },
selectedEvent: null, selectedEvent: null,
@ -63,7 +66,7 @@ export default {
showMyCalendar: false, showMyCalendar: false,
calendarOptions: { calendarOptions: {
locale: frLocale, locale: frLocale,
plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin ], plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin ],
initialView: 'timeGridWeek', initialView: 'timeGridWeek',
initialDate: window.startDate !== undefined ? window.startDate : new Date(), initialDate: window.startDate !== undefined ? window.startDate : new Date(),
eventSource: [], eventSource: [],
@ -75,6 +78,7 @@ export default {
// eventMouseLeave: this.onEventMouseLeave, // eventMouseLeave: this.onEventMouseLeave,
selectMirror: true, selectMirror: true,
editable: true, editable: true,
weekends: false,
headerToolbar: { headerToolbar: {
left: 'prev,next today', left: 'prev,next today',
center: 'title', center: 'title',
@ -85,12 +89,14 @@ export default {
}, },
methods: { methods: {
init() { init() {
console.log(window.startDate);
this.updateEventsSource(); this.updateEventsSource();
}, },
toggleMyCalendar(value) { toggleMyCalendar(value) {
this.showMyCalendar = value; this.showMyCalendar = value;
}, },
toggleWeekends: function() {
this.calendarOptions.weekends = !this.calendarOptions.weekends;
},
updateEventsSource() { updateEventsSource() {
this.calendarOptions.eventSources = []; this.calendarOptions.eventSources = [];
this.calendarOptions.eventSources.push(...this.calendarEvents.selected); this.calendarOptions.eventSources.push(...this.calendarEvents.selected);
@ -100,7 +106,6 @@ export default {
if (this.showMyCalendar) { if (this.showMyCalendar) {
this.calendarOptions.eventSources.push(this.calendarEvents.user); this.calendarOptions.eventSources.push(this.calendarEvents.user);
} }
console.log(this.calendarOptions.eventSources);
}, },
unSelectPreviousEvent(event) { unSelectPreviousEvent(event) {
if (event) { if (event) {
@ -108,15 +113,19 @@ export default {
event.setProp('backgroundColor', this.previousSelectedEventColor); event.setProp('backgroundColor', this.previousSelectedEventColor);
event.setProp('borderColor', this.previousSelectedEventColor); event.setProp('borderColor', this.previousSelectedEventColor);
event.setProp('textColor','#444444'); event.setProp('textColor','#444444');
event.setProp('title','');
} }
} }
}, },
onDateSelect(payload) { onDateSelect(payload) {
console.log(payload)
this.unSelectPreviousEvent(this.selectedEvent);
Object.assign(payload, {users: this.users}); Object.assign(payload, {users: this.users});
Object.assign(payload, {title: 'Choisir cette plage'}); //TODO does not display
//payload.event.setProp('title', 'Choisir cette plage');
this.$store.dispatch('createEvent', payload); this.$store.dispatch('createEvent', payload);
}, },
onEventChange(payload) { onEventChange(payload) {
console.log(this.calendarOptions.eventSources)
this.$store.dispatch('updateEvent', payload); this.$store.dispatch('updateEvent', payload);
}, },
onEventClick(payload) { onEventClick(payload) {
@ -124,8 +133,8 @@ export default {
this.previousSelectedEventColor = payload.event.extendedProps.sourceColor; this.previousSelectedEventColor = payload.event.extendedProps.sourceColor;
this.selectedEvent = payload.event; this.selectedEvent = payload.event;
this.unSelectPreviousEvent(this.previousSelectedEvent); this.unSelectPreviousEvent(this.previousSelectedEvent);
payload.event.setProp('backgroundColor','#df4949'); payload.event.setProp('backgroundColor','#3788d8');
payload.event.setProp('borderColor','#df4949'); payload.event.setProp('borderColor','#3788d8');
payload.event.setProp('title', 'Choisir cette plage'); payload.event.setProp('title', 'Choisir cette plage');
payload.event.setProp('textColor','#ffffff'); payload.event.setProp('textColor','#ffffff');
}, },

View File

@ -23,6 +23,11 @@
<input type="checkbox" id="myCalendar" class="form-check-input" v-model="showMyCalendarWidget" /> <input type="checkbox" id="myCalendar" class="form-check-input" v-model="showMyCalendarWidget" />
<label class="form-check-label" for="myCalendar">{{ $t('show_my_calendar') }}</label> <label class="form-check-label" for="myCalendar">{{ $t('show_my_calendar') }}</label>
</div> </div>
<div class="form-check">
<input type="checkbox" id="weekends" class="form-check-input" @click="toggleWeekends" />
<label class="form-check-label" for="weekends">{{ $t('show_weekends') }}</label>
</div>
</template> </template>
<script> <script>
@ -48,7 +53,7 @@ const COLORS = [ /* from https://colorbrewer2.org/#type=qualitative&scheme=Set3&
export default { export default {
name: 'CalendarUserSelector', name: 'CalendarUserSelector',
components: { VueMultiselect }, components: { VueMultiselect },
props: ['users', 'updateEventsSource', 'calendarEvents', 'showMyCalendar', 'toggleMyCalendar'], props: ['users', 'updateEventsSource', 'calendarEvents', 'showMyCalendar', 'toggleMyCalendar', 'toggleWeekends'],
data() { data() {
return { return {
errorMsg: [], errorMsg: [],
@ -104,15 +109,13 @@ export default {
events: arr, events: arr,
color: u.color, color: u.color,
textColor: '#444444', textColor: '#444444',
editable: false,
id: u.id id: u.id
}) })
}) })
this.users.loaded = users; this.users.loaded = users;
this.options = users; this.options = users;
console.log(users)
console.log(calendarEvents)
this.calendarEvents.loaded = calendarEvents; this.calendarEvents.loaded = calendarEvents;
whoami().then(me => new Promise((resolve, reject) => { whoami().then(me => new Promise((resolve, reject) => {
@ -131,7 +134,8 @@ export default {
let calendarEventsCurrentUser = { let calendarEventsCurrentUser = {
events: events, events: events,
color: 'darkblue', color: 'darkblue',
id: 1000 id: 1000,
editable: false
}; };
this.calendarEvents.user = calendarEventsCurrentUser; this.calendarEvents.user = calendarEventsCurrentUser;

View File

@ -2,7 +2,8 @@ const calendarUserSelectorMessages = {
fr: { fr: {
choose_your_calendar_user: "Afficher les plages de disponibilités", choose_your_calendar_user: "Afficher les plages de disponibilités",
select_user: "Sélectionnez des calendriers", select_user: "Sélectionnez des calendriers",
show_my_calendar: "Afficher mon calendrier" show_my_calendar: "Afficher mon calendrier",
show_weekends: "Afficher les week-ends"
} }
}; };

View File

@ -19,6 +19,7 @@ Send s m s: Envoi d'un SMS ?
Cancel reason: Motif d'annulation Cancel reason: Motif d'annulation
Add a new calendar: Ajouter un nouveau rendez-vous Add a new calendar: Ajouter un nouveau rendez-vous
"Success : calendar item updated!": "Rendez-vous mis à jour" "Success : calendar item updated!": "Rendez-vous mis à jour"
"Success : calendar item created!": "Rendez-vous créé"
The calendar item has been successfully removed.: Le rendez-vous a été supprimé The calendar item has been successfully removed.: Le rendez-vous a été supprimé
From the day: Du From the day: Du
to the day: au to the day: au