Appointment management modal is not updated after appointment duration resize (#155).

This commit is contained in:
alext 2018-01-17 22:06:42 +01:00
parent 62b74e8e75
commit 7aae2f359b
1 changed files with 17 additions and 7 deletions

View File

@ -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);