Renamed the helper and removed code that does not apply to the general settings page any more

This commit is contained in:
alextselegidis 2021-11-18 08:58:19 +01:00
parent 2d1fb357c8
commit d00a8956d7
2 changed files with 7 additions and 48 deletions

View file

@ -44,31 +44,10 @@ window.BackendSettingsGeneral = window.BackendSettingsGeneral || {};
GlobalVariables.settings.system.forEach(function (setting) { GlobalVariables.settings.system.forEach(function (setting) {
$('input[data-field="' + setting.name + '"]').val(setting.value); $('input[data-field="' + setting.name + '"]').val(setting.value);
$('select[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. // Set default settings helper.
settings = new SystemSettingsGeneral(); settings = new SystemSettingsGeneralHelper();
if (defaultEventHandlers) { if (defaultEventHandlers) {
bindEventHandlers(); bindEventHandlers();

View file

@ -15,9 +15,9 @@
/** /**
* "System Settings" Tab Helper Class * "System Settings" Tab Helper Class
* *
* @class SystemSettingsGeneral * @class SystemSettingsGeneralHelper
*/ */
var SystemSettingsGeneral = function () {}; var SystemSettingsGeneralHelper = function () {};
/** /**
* Save the system settings. * Save the system settings.
@ -26,7 +26,7 @@
* *
* @param {Array} settings Contains the system settings data. * @param {Array} settings Contains the system settings data.
*/ */
SystemSettingsGeneral.prototype.save = function (settings) { SystemSettingsGeneralHelper.prototype.save = function (settings) {
if (!this.validate()) { if (!this.validate()) {
return; // Validation failed, do not proceed. return; // Validation failed, do not proceed.
} }
@ -69,7 +69,7 @@
* *
* @return {Array} Returns the system settings array. * @return {Array} Returns the system settings array.
*/ */
SystemSettingsGeneral.prototype.get = function () { SystemSettingsGeneralHelper.prototype.get = function () {
var settings = []; var settings = [];
// General Settings Tab // 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; return settings;
}; };
@ -114,7 +94,7 @@
* *
* @return {Boolean} Returns the validation result. * @return {Boolean} Returns the validation result.
*/ */
SystemSettingsGeneral.prototype.validate = function () { SystemSettingsGeneralHelper.prototype.validate = function () {
$('#general .has-error').removeClass('has-error'); $('#general .has-error').removeClass('has-error');
try { try {
@ -144,5 +124,5 @@
} }
}; };
window.SystemSettingsGeneral = SystemSettingsGeneral; window.SystemSettingsGeneralHelper = SystemSettingsGeneralHelper;
})(); })();