From 74c10d3b7b385f8f22ba1e1a8b8275a079fd6bdf Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Thu, 7 May 2020 18:47:14 +0200 Subject: [PATCH] Converted hard coded HTML to jQuery generated markup. --- assets/css/general.css | 8 + .../js/backend_calendar_appointments_modal.js | 31 +- assets/js/backend_calendar_default_view.js | 318 ++++++++---- assets/js/backend_calendar_table_view.js | 313 ++++++++---- assets/js/backend_categories_helper.js | 29 +- assets/js/backend_customers_helper.js | 93 +++- assets/js/backend_services_helper.js | 50 +- assets/js/backend_users.js | 96 ++-- assets/js/backend_users_admins.js | 35 +- assets/js/backend_users_providers.js | 65 ++- assets/js/backend_users_secretaries.js | 47 +- assets/js/frontend_book.js | 164 ++++-- assets/js/frontend_book_api.js | 33 +- assets/js/frontend_book_success.js | 50 +- assets/js/general_functions.js | 35 -- assets/js/working_plan.js | 479 ++++++++++++++---- 16 files changed, 1279 insertions(+), 567 deletions(-) diff --git a/assets/css/general.css b/assets/css/general.css index b4c65a6a..d5e0e39a 100644 --- a/assets/css/general.css +++ b/assets/css/general.css @@ -395,3 +395,11 @@ li.language:hover { #message_box pre { max-height: 250px; } + +body .popover-content strong { + min-width: 80px; display:inline-block; +} + +body .popover-content button { + margin-right: 10px; +} diff --git a/assets/js/backend_calendar_appointments_modal.js b/assets/js/backend_calendar_appointments_modal.js index 81e8e593..a7e1f632 100755 --- a/assets/js/backend_calendar_appointments_modal.js +++ b/assets/js/backend_calendar_appointments_modal.js @@ -187,9 +187,12 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa $list.slideDown('slow'); $('#filter-existing-customers').fadeIn('slow'); $('#filter-existing-customers').val(''); - $.each(GlobalVariables.customers, function (index, c) { - $list.append('
' - + c.first_name + ' ' + c.last_name + '
'); + GlobalVariables.customers.forEach(function (customer) { + $('
', { + 'data-id': customer.id, + 'text': customer.first_name + ' ' + customer.last_name + }) + .appendTo($list); }); } else { $list.slideUp('slow'); @@ -241,9 +244,12 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa .done(function (response) { $list.empty(); - response.forEach(function (customer, index) { - $list.append('
' - + customer.first_name + ' ' + customer.last_name + '
'); + response.forEach(function (customer) { + $('
', { + 'data-id': customer.id, + 'text': customer.first_name + ' ' + customer.last_name + }) + .appendTo($list); // Verify if this customer is on the old customer list. var result = GlobalVariables.customers.filter(function(globalVariablesCustomer) { @@ -269,8 +275,11 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa || customer.city.toLowerCase().indexOf(key) !== -1 || customer.zip_code.toLowerCase().indexOf(key) !== -1 || customer.notes.toLowerCase().indexOf(key) !== -1) { - $list.append('
' - + customer.first_name + ' ' + customer.last_name + '
'); + $('
', { + 'data-id': customer.id, + 'text': customer.first_name + ' ' + customer.last_name + }) + .appendTo($list); } }); }); @@ -308,10 +317,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa // If the current provider is able to provide the selected service, add him to the listbox. if (Number(providerServiceId) === Number(serviceId)) { - var optionHtml = ''; - $('#select-provider').append(optionHtml); + $('#select-provider') + .append(new Option(provider.first_name + ' ' + provider.last_name, provider.id)); } }); }); diff --git a/assets/js/backend_calendar_default_view.js b/assets/js/backend_calendar_default_view.js index e8b43883..fae70db8 100755 --- a/assets/js/backend_calendar_default_view.js +++ b/assets/js/backend_calendar_default_view.js @@ -279,7 +279,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; function calendarEventClick(event, jsEvent, view) { $('.popover').remove(); // Close all open popovers. - var html; + var $html; var displayEdit; var displayDelete; @@ -301,109 +301,217 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; notes = 'Notes ' + event.data.notes; } - html = - '' + - '' + EALang.start + ' ' - + GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) - + '
' + - '' + EALang.end + ' ' - + GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) - + '
' - + notes - + '
' + - '
' + - '' + - '' + - '' + - '
'; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': notes + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '' + - ''; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.provider + }), + $('', { + 'text': event.data ? event.data.first_name + ' ' + event.data.last_name : '-' + }), + $('
'), + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.timezone + }), + $('', { + 'text': GlobalVariables.timezones[event.data.provider.timezone] + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '' + - '' + - '
'; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.timezone + }), + $('', { + 'text': GlobalVariables.timezones[event.data.provider.timezone] + }), + $('
'), + + $('', { + 'text': EALang.service + }), + $('', { + 'text': event.data.service.name + }), + $('
'), + + $('', { + 'text': EALang.provider + }), + GeneralFunctions.renderMapIcon(event.data.provider), + $('', { + 'text': event.data.provider.first_name + ' ' + event.data.provider.last_name + }), + $('
'), + + $('', { + 'text': EALang.customer + }), + GeneralFunctions.renderMapIcon(event.data.customer), + $('', { + 'text': event.data.customer.first_name + ' ' + event.data.customer.last_name + }), + $('
'), + + $('', { + 'text': EALang.email + }), + GeneralFunctions.renderMailIcon(event.data.customer.email), + $('', { + 'text': event.data.customer.email + }), + $('
'), + + $('', { + 'text': EALang.phone_number + }), + GeneralFunctions.renderPhoneIcon(event.data.customer.phone_number), + $('', { + 'text': event.data.customer.phone_number + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '' + - '' - ); + $('' + - '' + - '' + - ''; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': notes + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '' + - ''; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.provider + }), + $('', { + 'text': event.data ? event.data.first_name + ' ' + event.data.last_name : '-' + }), + $('
'), + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.timezone + }), + $('', { + 'text': GlobalVariables.timezones[event.data.provider.timezone] + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '' + - '' + - '
'; + $html = $('
', { + 'html': [ + $('', { + 'text': EALang.start + }), + $('', { + 'text': GeneralFunctions.formatDate(event.start.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.end + }), + $('', { + 'text': GeneralFunctions.formatDate(event.end.format('YYYY-MM-DD HH:mm:ss'), GlobalVariables.dateFormat, true) + }), + $('
'), + + $('', { + 'text': EALang.timezone + }), + $('', { + 'text': GlobalVariables.timezones[event.data.provider.timezone] + }), + $('
'), + + $('', { + 'text': EALang.service + }), + $('', { + 'text': event.data.service.name + }), + $('
'), + + $('', { + 'text': EALang.provider + }), + GeneralFunctions.renderMapIcon(event.data.provider), + $('', { + 'text': event.data.provider.first_name + ' ' + event.data.provider.last_name + }), + $('
'), + + $('', { + 'text': EALang.customer + }), + GeneralFunctions.renderMapIcon(event.data.customer), + $('', { + 'text': event.data.customer.first_name + ' ' + event.data.customer.last_name + }), + $('
'), + + $('', { + 'text': EALang.email + }), + GeneralFunctions.renderMailIcon(event.data.customer.email), + $('', { + 'text': event.data.customer.email + }), + $('
'), + + $('', { + 'text': EALang.phone_number + }), + GeneralFunctions.renderPhoneIcon(event.data.customer.phone_number), + $('', { + 'text': event.data.customer.phone_number + }), + $('
'), + + $('
'), + + $('
', { + 'class': 'text-center', + 'html': [ + $('' + - '
' + - '
'; - - $.each(exceptions, function (index, exception) { - html += - '
' + - '
' + - '
' + exception.message + '
' + - '
' + - '
'; - }); - - html += '
'; - - return html; - }; /** * Makes the first letter of the string upper case. diff --git a/assets/js/working_plan.js b/assets/js/working_plan.js index 896e79f5..2ad7adca 100755 --- a/assets/js/working_plan.js +++ b/assets/js/working_plan.js @@ -52,28 +52,59 @@ $('.breaks tbody').empty(); // Build working plan day list starting with the first weekday as set in the General settings - $.each(workingPlanSorted, function (index, workingDay) { + var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'; + $.each(workingPlanSorted, function (index, workingDay) { var day = this.convertValueToDay(index); + var dayTranslatedName = GeneralFunctions.upperCaseFirstLetter(day) - var tr = - '' + - '' + - '
' + - '' + - '
' + - '' + - '' + - '' + - ''; - - $('.working-plan tbody').append(tr); + $('', { + 'html': [ + $('', { + 'html': [ + $('
', { + 'class': 'checkbox', + 'html': [ + $('