From 7aae2f359bd5e1e97d4d55b3cfd1ac54b087523d Mon Sep 17 00:00:00 2001 From: alext Date: Wed, 17 Jan 2018 22:06:42 +0100 Subject: [PATCH] Appointment management modal is not updated after appointment duration resize (#155). --- .../js/backend_calendar_default_view.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/assets/js/backend_calendar_default_view.js b/src/assets/js/backend_calendar_default_view.js index 89c98064..f9a0e837 100644 --- a/src/assets/js/backend_calendar_default_view.js +++ b/src/assets/js/backend_calendar_default_view.js @@ -374,12 +374,19 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; return; } + var $calendar = $('#calendar'); + if ($('#notification').is(':visible')) { $('#notification').hide('bind'); } if (event.data.is_unavailable == false) { // Prepare appointment data. + event.data.end_datetime = Date.parseExact( + event.data.end_datetime, 'yyyy-MM-dd HH:mm:ss') + .add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()}) + .toString('yyyy-MM-dd HH:mm:ss'); + var appointment = GeneralFunctions.clone(event.data); // Must delete the following because only appointment data should be provided to the AJAX call. @@ -387,11 +394,6 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; delete appointment.provider; delete appointment.service; - appointment.end_datetime = Date.parseExact( - appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss') - .add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()}) - .toString('yyyy-MM-dd HH:mm:ss'); - // Success callback var successCallback = function (response) { if (response.exceptions) { @@ -410,7 +412,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; // Display success notification to user. var undoFunction = function () { - appointment.end_datetime = Date.parseExact( + appointment.end_datetime = event.data.end_datetime = Date.parseExact( appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss') .add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()}) .toString('yyyy-MM-dd HH:mm:ss'); @@ -435,6 +437,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; } ]); $('#footer').css('position', 'static'); // Footer position fix. + + // Update the event data for later use. + $calendar.fullCalendar('updateEvent', event); }; // Update appointment data. @@ -448,6 +453,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; id_users_provider: event.data.id_users_provider }; + event.data.end_datetime = unavailable.end_datetime; + // Define success callback function. var successCallback = function (response) { if (response.exceptions) { @@ -466,7 +473,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; // Display success notification to user. var undoFunction = function () { - unavailable.end_datetime = Date.parseExact( + unavailable.end_datetime = event.data.end_datetime = Date.parseExact( unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss') .add({minutes: -delta.minutes()}) .toString('yyyy-MM-dd HH:mm:ss'); @@ -491,6 +498,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; ]); $('#footer').css('position', 'static'); // Footer position fix. + + // Update the event data for later use. + $calendar.fullCalendar('updateEvent', event); }; BackendCalendarApi.saveUnavailable(unavailable, successCallback);