From afad23eb0f0d8498bfa6ce6ba94bd3bf913c9d57 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 16 Aug 2021 15:39:12 +0200 Subject: [PATCH] rdv: fix timezone issue for editing events --- .../Resources/public/vuejs/Calendar/store.js | 16 +++++++++++--- .../CalendarEvent/CalendarEvent.vue | 22 ++++++++++++++----- .../Calendar/editAccompanyingCourse.html.twig | 4 ++-- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js index aa141fc78..79c3db5d0 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js @@ -107,14 +107,24 @@ const store = createStore({ }, // Calendar - setDateRange({ commit }, payload) { - console.log('### action setDateRange', payload); + createEvent({ commit }, payload) { + console.log('### action createEvent', payload); let startDateInput = document.getElementById("chill_calendarbundle_calendar_startDate"); startDateInput.value = payload.startStr; let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate"); endDateInput.value = payload.endStr; commit('setEvents', payload); - } + }, + updateEvent({ commit }, payload) { + console.log('### action updateEvent', payload); + let startDateInput = document.getElementById("chill_calendarbundle_calendar_startDate"); + console.log(payload.event) + startDateInput.value = payload.event.start.toISOString(); + let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate"); + endDateInput.value = payload.event.end.toISOString(); + commit('setEvents', payload); + }, + } }); diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarEvent/CalendarEvent.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarEvent/CalendarEvent.vue index a3cf011f0..d0012dd1f 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarEvent/CalendarEvent.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarEvent/CalendarEvent.vue @@ -21,19 +21,21 @@ export default { return { calendarOptions: { plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin ], - initialView: 'dayGridMonth', + initialView: 'timeGridWeek', initialEvents: window.startDate !== undefined ? [ { id: 1, - start: window.startDate.date, - end: window.endDate.date + start: window.startDate, + end: window.endDate } ] : [], - initialDate: window.startDate !== undefined ? window.startDate.date : new Date(), + initialDate: window.startDate !== undefined ? window.startDate : new Date(), selectable: true, select: this.onDateSelect, + eventChange: this.onEventChange, selectMirror: true, + editable: true, headerToolbar: { left: 'prev,next today', center: 'title', @@ -44,8 +46,16 @@ export default { }, methods: { onDateSelect(payload) { - this.$store.dispatch('setDateRange', payload); + this.$store.dispatch('createEvent', payload); + }, + onEventChange(payload) { + this.$store.dispatch('updateEvent', payload); } - } + }, + // mounted() { + // console.log(window.startDate); + // console.log(window.endDate); + // console.log(window.date); + // } } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editAccompanyingCourse.html.twig index 91bc83b4a..17e15df66 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editAccompanyingCourse.html.twig @@ -25,8 +25,8 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.entity = {{ entity_json|json_encode|raw }}; - window.startDate = {{ entity.startDate|json_encode|raw }}; - window.endDate = {{ entity.endDate|json_encode|raw }}; + window.startDate = {{ entity.startDate|date('Y-m-d H:i:s')|json_encode|raw }}; + window.endDate = {{ entity.endDate|date('Y-m-d H:i:s')|json_encode|raw }}; {{ encore_entry_script_tags('vue_calendar') }} {% endblock %}