Changed object properties reference style.

This commit is contained in:
alext 2017-11-02 14:19:54 +01:00
parent 89890dab4f
commit 7bfff7bfe0
9 changed files with 77 additions and 77 deletions

View file

@ -117,12 +117,12 @@ window.Backend = window.Backend || {};
var customActionsHtml = ''; var customActionsHtml = '';
$.each(actions, function(index, action) { $.each(actions, function(index, action) {
var actionId = action['label'].toLowerCase().replace(' ', '-'); var actionId = action.label.toLowerCase().replace(' ', '-');
customActionsHtml += '<button id="' + actionId + '" class="btn btn-default btn-xs">' customActionsHtml += '<button id="' + actionId + '" class="btn btn-default btn-xs">'
+ action['label'] + '</button>'; + action.label + '</button>';
$(document).off('click', '#' + actionId); $(document).off('click', '#' + actionId);
$(document).on('click', '#' + actionId, action['function']); $(document).on('click', '#' + actionId, action.function);
}); });
var notificationHtml = var notificationHtml =

View file

@ -34,20 +34,20 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
* @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure. * @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure.
*/ */
exports.saveAppointment = function(appointment, customer, successCallback, errorCallback) { exports.saveAppointment = function(appointment, customer, successCallback, errorCallback) {
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment'; var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
appointment_data: JSON.stringify(appointment) appointment_data: JSON.stringify(appointment)
}; };
if (customer !== undefined) { if (customer !== undefined) {
postData['customer_data'] = JSON.stringify(customer); data.customer_data = JSON.stringify(customer);
} }
$.ajax({ $.ajax({
url: postUrl, url: url,
type: 'POST', type: 'POST',
data: postData, data: data,
dataType: 'json' dataType: 'json'
}) })
.done(function(response) { .done(function(response) {

View file

@ -63,7 +63,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
if ($dialog.find('#appointment-id').val() !== '') { if ($dialog.find('#appointment-id').val() !== '') {
// Set the id value, only if we are editing an appointment. // Set the id value, only if we are editing an appointment.
appointment['id'] = $dialog.find('#appointment-id').val(); appointment.id = $dialog.find('#appointment-id').val();
} }
var customer = { var customer = {
@ -79,8 +79,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
if ($dialog.find('#customer-id').val() !== '') { if ($dialog.find('#customer-id').val() !== '') {
// Set the id value, only if we are editing an appointment. // Set the id value, only if we are editing an appointment.
customer['id'] = $dialog.find('#customer-id').val(); customer.id = $dialog.find('#customer-id').val();
appointment['id_users_customer'] = customer['id']; appointment.id_users_customer = customer.id;
} }
// Define success callback. // Define success callback.
@ -144,8 +144,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
var serviceDuration = 0; var serviceDuration = 0;
$.each(GlobalVariables.availableServices, function(index, service) { $.each(GlobalVariables.availableServices, function(index, service) {
if (service['id'] == $dialog.find('#select-service').val()) { if (service.id == $dialog.find('#select-service').val()) {
serviceDuration = service['duration']; serviceDuration = service.duration;
return false; // exit loop return false; // exit loop
} }
}); });
@ -299,8 +299,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
$.each(provider.services, function(indexService, serviceId) { $.each(provider.services, function(indexService, serviceId) {
// If the current provider is able to provide the selected service, add him to the listbox. // If the current provider is able to provide the selected service, add him to the listbox.
if (serviceId == sid) { if (serviceId == sid) {
var optionHtml = '<option value="' + provider['id'] + '">' var optionHtml = '<option value="' + provider.id + '">'
+ provider['first_name'] + ' ' + provider['last_name'] + provider.first_name + ' ' + provider.last_name
+ '</option>'; + '</option>';
$('#select-provider').append(optionHtml); $('#select-provider').append(optionHtml);
} }
@ -340,7 +340,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
$.each(GlobalVariables.availableProviders, function(index, provider) { $.each(GlobalVariables.availableProviders, function(index, provider) {
var canProvideService = false; var canProvideService = false;
$.each(provider['services'], function(index, serviceId) { $.each(provider.services, function(index, serviceId) {
if (serviceId == $dialog.find('#select-service').val()) { if (serviceId == $dialog.find('#select-service').val()) {
canProvideService = true; canProvideService = true;
return false; return false;
@ -348,8 +348,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
}); });
if (canProvideService) { // Add the provider to the listbox. if (canProvideService) { // Add the provider to the listbox.
var option = new Option(provider['first_name'] var option = new Option(provider.first_name
+ ' ' + provider['last_name'], provider['id']); + ' ' + provider.last_name, provider.id);
$dialog.find('#select-provider').append(option); $dialog.find('#select-provider').append(option);
} }
}); });
@ -363,8 +363,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime. // Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
var serviceDuration = 0; var serviceDuration = 0;
$.each(GlobalVariables.availableServices, function(index, service) { $.each(GlobalVariables.availableServices, function(index, service) {
if (service['id'] == $dialog.find('#select-service').val()) { if (service.id == $dialog.find('#select-service').val()) {
serviceDuration = service['duration']; serviceDuration = service.duration;
return false; return false;
} }
}); });

View file

@ -94,11 +94,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
// Update page elements and make an AJAX call to remove the google sync setting of the // Update page elements and make an AJAX call to remove the google sync setting of the
// selected provider. // selected provider.
$.each(GlobalVariables.availableProviders, function(index, provider) { $.each(GlobalVariables.availableProviders, function(index, provider) {
if (provider['id'] == $('#select-filter-item').val()) { if (provider.id == $('#select-filter-item').val()) {
provider['settings']['google_sync'] = '0'; provider.settings.google_sync = '0';
provider['settings']['google_token'] = null; provider.settings.google_token = null;
_disableProviderSync(provider['id']); _disableProviderSync(provider.id);
$('#enable-sync').removeClass('btn-danger enabled'); $('#enable-sync').removeClass('btn-danger enabled');
$('#enable-sync span:eq(1)').text(EALang.enable_sync); $('#enable-sync span:eq(1)').text(EALang.enable_sync);

View file

@ -261,30 +261,30 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
// Apply appointment data and show modal dialog. // Apply appointment data and show modal dialog.
$dialog.find('.modal-header h3').text(EALang.edit_appointment_title); $dialog.find('.modal-header h3').text(EALang.edit_appointment_title);
$dialog.find('#appointment-id').val(appointment['id']); $dialog.find('#appointment-id').val(appointment.id);
$dialog.find('#select-service').val(appointment['id_services']).trigger('change'); $dialog.find('#select-service').val(appointment.id_services).trigger('change');
$dialog.find('#select-provider').val(appointment['id_users_provider']); $dialog.find('#select-provider').val(appointment.id_users_provider);
// Set the start and end datetime of the appointment. // Set the start and end datetime of the appointment.
var startDatetime = Date.parseExact(appointment['start_datetime'], var startDatetime = Date.parseExact(appointment.start_datetime,
'yyyy-MM-dd HH:mm:ss'); 'yyyy-MM-dd HH:mm:ss');
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime); $dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
var endDatetime = Date.parseExact(appointment['end_datetime'], var endDatetime = Date.parseExact(appointment.end_datetime,
'yyyy-MM-dd HH:mm:ss'); 'yyyy-MM-dd HH:mm:ss');
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime); $dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
var customer = appointment['customer']; var customer = appointment.customer;
$dialog.find('#customer-id').val(appointment['id_users_customer']); $dialog.find('#customer-id').val(appointment.id_users_customer);
$dialog.find('#first-name').val(customer['first_name']); $dialog.find('#first-name').val(customer.first_name);
$dialog.find('#last-name').val(customer['last_name']); $dialog.find('#last-name').val(customer.last_name);
$dialog.find('#email').val(customer['email']); $dialog.find('#email').val(customer.email);
$dialog.find('#phone-number').val(customer['phone_number']); $dialog.find('#phone-number').val(customer.phone_number);
$dialog.find('#address').val(customer['address']); $dialog.find('#address').val(customer.address);
$dialog.find('#city').val(customer['city']); $dialog.find('#city').val(customer.city);
$dialog.find('#zip-code').val(customer['zip_code']); $dialog.find('#zip-code').val(customer.zip_code);
$dialog.find('#appointment-notes').val(appointment['notes']); $dialog.find('#appointment-notes').val(appointment.notes);
$dialog.find('#customer-notes').val(customer['notes']); $dialog.find('#customer-notes').val(customer.notes);
} else { } else {
var unavailable = lastFocusedEventData; var unavailable = lastFocusedEventData;
@ -311,7 +311,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
/** /**
* Event: Popover Delete Button "Click" * Event: Popover Delete Button "Click"
* *
* Displays a prompt on whether the user wants the appoinmtent to be deleted. If he confirms the * Displays a prompt on whether the user wants the appointment to be deleted. If he confirms the
* deletion then an ajax call is made to the server and deletes the appointment from the database. * deletion then an ajax call is made to the server and deletes the appointment from the database.
*/ */
$calendar.on('click', '.delete-popover', function() { $calendar.on('click', '.delete-popover', function() {
@ -325,7 +325,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment'; var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment';
var postData = { var postData = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
appointment_id : lastFocusedEventData['id'], appointment_id : lastFocusedEventData.id,
delete_reason: $('#delete-reason').val() delete_reason: $('#delete-reason').val()
}; };

View file

@ -170,12 +170,12 @@ window.FrontendBook = window.FrontendBook || {};
$('#select-provider').empty(); $('#select-provider').empty();
$.each(GlobalVariables.availableProviders, function(indexProvider, provider) { $.each(GlobalVariables.availableProviders, function(indexProvider, provider) {
$.each(provider['services'], function(indexService, serviceId) { $.each(provider.services'], function(indexService, serviceId) {
// If the current provider is able to provide the selected service, // If the current provider is able to provide the selected service,
// add him to the listbox. // add him to the listbox.
if (serviceId == currServiceId) { if (serviceId == currServiceId) {
var optionHtml = '<option value="' + provider['id'] + '">' var optionHtml = '<option value="' + provider.id'] + '">'
+ provider['first_name'] + ' ' + provider['last_name'] + provider.first_name'] + ' ' + provider.last_name']
+ '</option>'; + '</option>';
$('#select-provider').append(optionHtml); $('#select-provider').append(optionHtml);
} }
@ -444,7 +444,7 @@ window.FrontendBook = window.FrontendBook || {};
// the appointment. // the appointment.
var postData = {}; var postData = {};
postData['customer'] = { postData.customer = {
last_name: $('#last-name').val(), last_name: $('#last-name').val(),
first_name: $('#first-name').val(), first_name: $('#first-name').val(),
email: $('#email').val(), email: $('#email').val(),
@ -454,7 +454,7 @@ window.FrontendBook = window.FrontendBook || {};
zip_code: $('#zip-code').val() zip_code: $('#zip-code').val()
}; };
postData['appointment'] = { postData.appointment = {
start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd') start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00', + ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00',
end_datetime: _calcEndDatetime(), end_datetime: _calcEndDatetime(),
@ -464,11 +464,11 @@ window.FrontendBook = window.FrontendBook || {};
id_services: $('#select-service').val() id_services: $('#select-service').val()
}; };
postData['manage_mode'] = FrontendBook.manageMode; postData.manage_mode = FrontendBook.manageMode;
if (FrontendBook.manageMode) { if (FrontendBook.manageMode) {
postData['appointment']['id'] = GlobalVariables.appointmentData['id']; postData.appointment.id = GlobalVariables.appointmentData.id;
postData['customer']['id'] = GlobalVariables.customerData['id']; postData.customer.id = GlobalVariables.customerData.id;
} }
$('input[name="csrfToken"]').val(GlobalVariables.csrfToken); $('input[name="csrfToken"]').val(GlobalVariables.csrfToken);
$('input[name="post_data"]').val(JSON.stringify(postData)); $('input[name="post_data"]').val(JSON.stringify(postData));
@ -519,24 +519,24 @@ window.FrontendBook = window.FrontendBook || {};
function _applyAppointmentData(appointment, provider, customer) { function _applyAppointmentData(appointment, provider, customer) {
try { try {
// Select Service & Provider // Select Service & Provider
$('#select-service').val(appointment['id_services']).trigger('change'); $('#select-service').val(appointment.id_services).trigger('change');
$('#select-provider').val(appointment['id_users_provider']); $('#select-provider').val(appointment.id_users_provider);
// Set Appointment Date // Set Appointment Date
$('#select-date').datepicker('setDate', $('#select-date').datepicker('setDate',
Date.parseExact(appointment['start_datetime'], 'yyyy-MM-dd HH:mm:ss')); Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss'));
FrontendBookApi.getAvailableHours($('#select-date').val()); FrontendBookApi.getAvailableHours($('#select-date').val());
// Apply Customer's Data // Apply Customer's Data
$('#last-name').val(customer['last_name']); $('#last-name').val(customer.last_name);
$('#first-name').val(customer['first_name']); $('#first-name').val(customer.first_name);
$('#email').val(customer['email']); $('#email').val(customer.email);
$('#phone-number').val(customer['phone_number']); $('#phone-number').val(customer.phone_number);
$('#address').val(customer['address']); $('#address').val(customer.address);
$('#city').val(customer['city']); $('#city').val(customer.city);
$('#zip-code').val(customer['zip_code']); $('#zip-code').val(customer.zip_code);
var appointmentNotes = (appointment['notes'] !== null) var appointmentNotes = (appointment.notes !== null)
? appointment['notes'] : ''; ? appointment.notes : '';
$('#notes').val(appointmentNotes); $('#notes').val(appointmentNotes);
FrontendBook.updateConfirmFrame(); FrontendBook.updateConfirmFrame();

View file

@ -40,13 +40,13 @@ window.FrontendBookApi = window.FrontendBookApi || {};
// Find the selected service duration (it is going to be send within the "postData" object). // Find the selected service duration (it is going to be send within the "postData" object).
var selServiceDuration = 15; // Default value of duration (in minutes). var selServiceDuration = 15; // Default value of duration (in minutes).
$.each(GlobalVariables.availableServices, function(index, service) { $.each(GlobalVariables.availableServices, function(index, service) {
if (service['id'] == $('#select-service').val()) { if (service.id == $('#select-service').val()) {
selServiceDuration = service['duration']; selServiceDuration = service.duration;
} }
}); });
// If the manage mode is true then the appointment's start date should return as available too. // If the manage mode is true then the appointment's start 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';
@ -86,7 +86,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
$('.available-hour').removeClass('selected-hour'); $('.available-hour').removeClass('selected-hour');
$('.available-hour').filter(function() { $('.available-hour').filter(function() {
return $(this).text() === Date.parseExact( return $(this).text() === Date.parseExact(
GlobalVariables.appointmentData['start_datetime'], GlobalVariables.appointmentData.start_datetime,
'yyyy-MM-dd HH:mm:ss').toString('h:mm tt'); 'yyyy-MM-dd HH:mm:ss').toString('h:mm tt');
}).addClass('selected-hour'); }).addClass('selected-hour');
} else { } else {

View file

@ -45,28 +45,28 @@ $(document).ready(function() {
// must be prepared. // must be prepared.
var appointmentData = GlobalVariables.appointmentData; var appointmentData = GlobalVariables.appointmentData;
appointmentData['start_datetime'] = GeneralFunctions.ISODateString( appointmentData.start_datetime = GeneralFunctions.ISODateString(
Date.parseExact(appointmentData['start_datetime'], Date.parseExact(appointmentData.start_datetime,
'yyyy-MM-dd HH:mm:ss')); 'yyyy-MM-dd HH:mm:ss'));
appointmentData['end_datetime'] = GeneralFunctions.ISODateString( appointmentData.end_datetime = GeneralFunctions.ISODateString(
Date.parseExact(appointmentData['end_datetime'], Date.parseExact(appointmentData.end_datetime,
'yyyy-MM-dd HH:mm:ss')); 'yyyy-MM-dd HH:mm:ss'));
// Create a valid Google Calendar API resource for the new event. // Create a valid Google Calendar API resource for the new event.
var resource = { var resource = {
summary: GlobalVariables.serviceData['name'], summary: GlobalVariables.serviceData.name,
location: GlobalVariables.companyName, location: GlobalVariables.companyName,
start: { start: {
dateTime: appointmentData['start_datetime'] dateTime: appointmentData.start_datetime
}, },
end: { end: {
dateTime: appointmentData['end_datetime'] dateTime: appointmentData.end_datetime
}, },
attendees: [ attendees: [
{ {
email: GlobalVariables.providerData['email'], email: GlobalVariables.providerData.email,
displayName: GlobalVariables.providerData['first_name'] + ' ' displayName: GlobalVariables.providerData.first_name + ' '
+ GlobalVariables.providerData['last_name'] + GlobalVariables.providerData.last_name
} }
] ]
}; };

View file

@ -242,7 +242,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
html += html +=
'<div id="error-technical" class="accordion-body collapse">' + '<div id="error-technical" class="accordion-body collapse">' +
'<div class="accordion-inner">' + '<div class="accordion-inner">' +
'<pre>' + exception['message'] + '</pre>' + '<pre>' + exception.message + '</pre>' +
'</div>' + '</div>' +
'</div>'; '</div>';
}); });