Enhancements in the fronted_book_api.js comments.

This commit is contained in:
Alex Tselegidis 2016-05-14 12:09:21 +02:00
parent 90bcd361da
commit 94a66cffad

View file

@ -23,11 +23,12 @@ window.FrontendBookApi = window.FrontendBookApi || {};
'use strict'; 'use strict';
/** /**
* This function makes an ajax call and returns the available * Get Available Hours
* hours for the selected service, provider and date.
* *
* @param {string} selDate The selected date of which the available * This function makes an AJAX call and returns the available hours for the selected service,
* hours we need to receive. * provider and date.
*
* @param {String} selDate The selected date of which the available hours we need to receive.
*/ */
exports.getAvailableHours = function(selDate) { exports.getAvailableHours = function(selDate) {
$('#available-hours').empty(); $('#available-hours').empty();
@ -40,9 +41,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
} }
}); });
// If the manage mode is true then the appointment's start // If the manage mode is true then the appointment's start date should return as available too.
// date should return as available too. var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData['id'] : undefined;
var appointmentId = (FrontendBook.manageMode) ? GlobalVariables.appointmentData['id'] : undefined;
// Make ajax post request and get the available hours. // Make ajax post request and get the available hours.
var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours', var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours',
@ -115,11 +115,10 @@ window.FrontendBookApi = window.FrontendBookApi || {};
} }
} }
var formData = jQuery.parseJSON($('input[name="post_data"]').val()); var formData = jQuery.parseJSON($('input[name="post_data"]').val()),
postData = {
var postData = { csrfToken: GlobalVariables.csrfToken,
'csrfToken': GlobalVariables.csrfToken, post_data: formData
'post_data': formData
}; };
if ($captchaText.length > 0) { if ($captchaText.length > 0) {
@ -190,12 +189,12 @@ window.FrontendBookApi = window.FrontendBookApi || {};
* Get the unavailable dates of a provider. * Get the unavailable dates of a provider.
* *
* This method will fetch the unavailable dates of the selected provider and service and then it will * This method will fetch the unavailable dates of the selected provider and service and then it will
* select the first available date (if any). It uses the "FrontendBookApi.getAvailableHours" method to fetch the appointment * select the first available date (if any). It uses the "FrontendBookApi.getAvailableHours" method to
* hours of the selected date. * fetch the appointment* hours of the selected date.
* *
* @param {int} providerId The selected provider ID. * @param {Number} providerId The selected provider ID.
* @param {int} serviceId The selected service ID. * @param {Number} serviceId The selected service ID.
* @param {string} selectedDateString Y-m-d value of the selected date. * @param {String} selectedDateString Y-m-d value of the selected date.
*/ */
exports.getUnavailableDates = function(providerId, serviceId, selectedDateString) { exports.getUnavailableDates = function(providerId, serviceId, selectedDateString) {
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates', var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates',