From a3dfb915504b6a125d72d2bb3cbf18c6bb4e0fcd Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 23 Sep 2020 13:48:07 +0300 Subject: [PATCH] Improvements in the user language storage feature. --- application/controllers/Appointments.php | 2 +- .../migrations/020_add_language_to_users.php | 2 +- assets/js/backend_customers.js | 4 +--- assets/js/backend_customers_helper.js | 15 ++++----------- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 3bc8268a..2d845cdc 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -1041,7 +1041,7 @@ class Appointments extends CI_Controller { $appointment['location'] = $service['location']; } - // save customer language (the language which is used to render the booking page) + // Save customer language (the language which is used to render the booking page). $customer['language'] = $this->config->item('language'); $customer_id = $this->customers_model->add($customer); diff --git a/application/migrations/020_add_language_to_users.php b/application/migrations/020_add_language_to_users.php index 2a28bc02..329b74df 100644 --- a/application/migrations/020_add_language_to_users.php +++ b/application/migrations/020_add_language_to_users.php @@ -29,7 +29,7 @@ class Migration_Add_language_to_users extends CI_Migration { 'language' => [ 'type' => 'VARCHAR', 'constraint' => '256', - 'default' => '', + 'default' => 'english', 'after' => 'timezone' ] ]; diff --git a/assets/js/backend_customers.js b/assets/js/backend_customers.js index ccf52b6a..21770c70 100644 --- a/assets/js/backend_customers.js +++ b/assets/js/backend_customers.js @@ -42,13 +42,11 @@ window.BackendCustomers = window.BackendCustomers || {}; exports.initialize = function (defaultEventHandlers) { defaultEventHandlers = defaultEventHandlers || false; - // Fill available service categories listbox. + // Add the available languages to the language dropdown. availableLanguages.forEach(function (language) { $('#language').append(new Option(language, language)); }); - $('#language').append(new Option('- ' + EALang.no_language + ' -', null)).val('null'); - helper = new CustomersHelper(); helper.resetForm(); helper.filter(''); diff --git a/assets/js/backend_customers_helper.js b/assets/js/backend_customers_helper.js index ffd038fc..bc894f51 100644 --- a/assets/js/backend_customers_helper.js +++ b/assets/js/backend_customers_helper.js @@ -125,15 +125,10 @@ city: $('#city').val(), zip_code: $('#zip-code').val(), notes: $('#notes').val(), - timezone: $('#timezone').val() + timezone: $('#timezone').val(), + language: $('#language').val() || 'english' }; - if ($('#language').val() !== 'null') { - customer.language = $('#language').val(); - } else { - customer.language = ''; - } - if ($('#customer-id').val()) { customer.id = $('#customer-id').val(); } @@ -265,7 +260,7 @@ .val('') .prop('disabled', true); - $('#language').val('null'); + $('#language').val('english'); $('#customer-appointments').empty(); $('#edit-customer, #delete-customer').prop('disabled', true); @@ -296,9 +291,7 @@ $('#zip-code').val(customer.zip_code); $('#notes').val(customer.notes); $('#timezone').val(customer.timezone); - - var language = (customer.language !== '') ? customer.language : 'null'; - $('#language').val(language); + $('#language').val(customer.language || 'english'); $('#customer-appointments').empty();