From d00a8956d7aaa7a70cf9fc46e841352f52db4966 Mon Sep 17 00:00:00 2001 From: alextselegidis Date: Thu, 18 Nov 2021 08:58:19 +0100 Subject: [PATCH] Renamed the helper and removed code that does not apply to the general settings page any more --- assets/js/backend_settings_general.js | 23 +------------- assets/js/backend_settings_general_helper.js | 32 ++++---------------- 2 files changed, 7 insertions(+), 48 deletions(-) diff --git a/assets/js/backend_settings_general.js b/assets/js/backend_settings_general.js index 16255183..8165887b 100644 --- a/assets/js/backend_settings_general.js +++ b/assets/js/backend_settings_general.js @@ -44,31 +44,10 @@ window.BackendSettingsGeneral = window.BackendSettingsGeneral || {}; GlobalVariables.settings.system.forEach(function (setting) { $('input[data-field="' + setting.name + '"]').val(setting.value); $('select[data-field="' + setting.name + '"]').val(setting.value); - - if (setting.name === 'customer_notifications') { - $('#customer-notifications').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_captcha') { - $('#require-captcha').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_phone_number') { - $('#require-phone-number').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_any_provider') { - $('#display-any-provider').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_cookie_notice') { - $('#display-cookie-notice').prop('checked', Boolean(Number(setting.value))); - } - }); // Set default settings helper. - settings = new SystemSettingsGeneral(); + settings = new SystemSettingsGeneralHelper(); if (defaultEventHandlers) { bindEventHandlers(); diff --git a/assets/js/backend_settings_general_helper.js b/assets/js/backend_settings_general_helper.js index 1598abec..f65d4718 100644 --- a/assets/js/backend_settings_general_helper.js +++ b/assets/js/backend_settings_general_helper.js @@ -15,9 +15,9 @@ /** * "System Settings" Tab Helper Class * - * @class SystemSettingsGeneral + * @class SystemSettingsGeneralHelper */ - var SystemSettingsGeneral = function () {}; + var SystemSettingsGeneralHelper = function () {}; /** * Save the system settings. @@ -26,7 +26,7 @@ * * @param {Array} settings Contains the system settings data. */ - SystemSettingsGeneral.prototype.save = function (settings) { + SystemSettingsGeneralHelper.prototype.save = function (settings) { if (!this.validate()) { return; // Validation failed, do not proceed. } @@ -69,7 +69,7 @@ * * @return {Array} Returns the system settings array. */ - SystemSettingsGeneral.prototype.get = function () { + SystemSettingsGeneralHelper.prototype.get = function () { var settings = []; // General Settings Tab @@ -84,26 +84,6 @@ }); }); - settings.push({ - name: 'customer_notifications', - value: $('#customer-notifications').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_captcha', - value: $('#require-captcha').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_phone_number', - value: $('#require-phone-number').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'display_any_provider', - value: $('#display-any-provider').prop('checked') ? '1' : '0' - }); - return settings; }; @@ -114,7 +94,7 @@ * * @return {Boolean} Returns the validation result. */ - SystemSettingsGeneral.prototype.validate = function () { + SystemSettingsGeneralHelper.prototype.validate = function () { $('#general .has-error').removeClass('has-error'); try { @@ -144,5 +124,5 @@ } }; - window.SystemSettingsGeneral = SystemSettingsGeneral; + window.SystemSettingsGeneralHelper = SystemSettingsGeneralHelper; })();