From e0874149b4e2de2491f80f572b6f46f9489202db Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 18 Dec 2021 19:02:56 +0100 Subject: [PATCH] Removed obsolete JS files --- .../js/pages/backend_settings_current_user.js | 94 ------------- .../backend_settings_current_user_helper.js | 131 ------------------ 2 files changed, 225 deletions(-) delete mode 100644 assets/js/pages/backend_settings_current_user.js delete mode 100644 assets/js/pages/backend_settings_current_user_helper.js diff --git a/assets/js/pages/backend_settings_current_user.js b/assets/js/pages/backend_settings_current_user.js deleted file mode 100644 index 38e55756..00000000 --- a/assets/js/pages/backend_settings_current_user.js +++ /dev/null @@ -1,94 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) Alex Tselegidis - * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link https://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -window.BackendSettingsCurrentUser = window.BackendSettingsCurrentUser || {}; - -/** - * Backend Settings - * - * Contains the functionality of the backend settings page. Can either work for system or user settings, - * but the actions allowed to the user are restricted to his role (only admin has full privileges). - * - * @module BackendSettingsCurrentUser - */ -(function (exports) { - 'use strict'; - - // Constants - exports.SETTINGS_USER = 'SETTINGS_USER'; - - /** - * Use this WorkingPlan class instance to perform actions on the page's working plan tables. - * - * @type {WorkingPlan} - */ - exports.wp = {}; - - /** - * Tab settings object. - * - * @type {Object} - */ - var settings = {}; - - /** - * Initialize Page - * - * @param {bool} defaultEventHandlers Optional (true), determines whether to bind the default event handlers. - */ - exports.initialize = function (defaultEventHandlers) { - defaultEventHandlers = defaultEventHandlers || true; - - // Load user settings into form - $('#user-id').val(GlobalVariables.settings.user.id); - $('#first-name').val(GlobalVariables.settings.user.first_name); - $('#last-name').val(GlobalVariables.settings.user.last_name); - $('#email').val(GlobalVariables.settings.user.email); - $('#mobile-number').val(GlobalVariables.settings.user.mobile_number); - $('#phone-number').val(GlobalVariables.settings.user.phone_number); - $('#address').val(GlobalVariables.settings.user.address); - $('#city').val(GlobalVariables.settings.user.city); - $('#state').val(GlobalVariables.settings.user.state); - $('#zip-code').val(GlobalVariables.settings.user.zip_code); - $('#notes').val(GlobalVariables.settings.user.notes); - $('#timezone').val(GlobalVariables.settings.user.timezone); - $('#username').val(GlobalVariables.settings.user.settings.username); - $('#password, #retype-password').val(''); - $('#calendar-view').val(GlobalVariables.settings.user.settings.calendar_view); - $('#user-notifications').prop('checked', Boolean(Number(GlobalVariables.settings.user.settings.notifications))); - - // Set default settings helper. - settings = new SystemSettingsCurrentUserHelper(); - - if (defaultEventHandlers) { - bindEventHandlers(); - } - - Backend.placeFooterToBottom(); - }; - - /** - * Bind the backend/settings default event handlers. - * - * This method depends on the backend/settings html, so do not use this method on a different page. - */ - function bindEventHandlers() { - /** - * Event: Save Settings Button "Click" - * - * Store the setting changes into the database. - */ - $('.save-settings').on('click', function () { - var data = settings.get(); - settings.save(data); - }); - } -})(window.BackendSettingsCurrentUser); diff --git a/assets/js/pages/backend_settings_current_user_helper.js b/assets/js/pages/backend_settings_current_user_helper.js deleted file mode 100644 index bab64f19..00000000 --- a/assets/js/pages/backend_settings_current_user_helper.js +++ /dev/null @@ -1,131 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) Alex Tselegidis - * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link https://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -(function () { - 'use strict'; - - /** - * "User Settings" Tab Helper Class - * - * @class SystemSettingsCurrentUserHelper - */ - var SystemSettingsCurrentUserHelper = function () {}; - - /** - * Get the settings data for the user settings. - * - * @return {Object} Returns the user settings array. - */ - SystemSettingsCurrentUserHelper.prototype.get = function () { - var user = { - id: $('#user-id').val(), - first_name: $('#first-name').val(), - last_name: $('#last-name').val(), - email: $('#email').val(), - mobile_number: $('#mobile-number').val(), - phone_number: $('#phone-number').val(), - address: $('#address').val(), - city: $('#city').val(), - state: $('#state').val(), - zip_code: $('#zip-code').val(), - notes: $('#notes').val(), - timezone: $('#timezone').val(), - settings: { - username: $('#username').val(), - notifications: $('#user-notifications').prop('checked'), - calendar_view: $('#calendar-view').val() - } - }; - - if ($('#password').val()) { - user.settings.password = $('#password').val(); - } - - return user; - }; - - /** - * Store the user settings into the database. - * - * @param {Array} settings Contains the user settings. - */ - SystemSettingsCurrentUserHelper.prototype.save = function (settings) { - if (!this.validate(settings)) { - Backend.displayNotification(App.Lang.user_settings_are_invalid); - return; // Validation failed, do not proceed. - } - - var url = GlobalVariables.baseUrl + '/index.php/account_settings/save'; - - var data = { - csrf_token: GlobalVariables.csrfToken, - type: BackendSettingsCurrentUser.SETTINGS_USER, - settings: JSON.stringify(settings) - }; - - $.post(url, data).done(function () { - Backend.displayNotification(App.Lang.settings_saved); - - // Update footer greetings. - $('#footer-user-display-name').text('Hello, ' + $('#first-name').val() + ' ' + $('#last-name').val() + '!'); - }); - }; - - /** - * Validate the settings data. - * - * If the validation fails then display a message to the user. - * - * @return {Boolean} Returns the validation result. - */ - SystemSettingsCurrentUserHelper.prototype.validate = function () { - $('#current-user .is-invalid').removeClass('is-invalid'); - - try { - // Validate required fields. - var missingRequired = false; - $('#current-user .required').each(function (index, requiredField) { - if (!$(requiredField).val()) { - $(requiredField).addClass('is-invalid'); - missingRequired = true; - } - }); - - if (missingRequired) { - throw new Error(App.Lang.fields_are_required); - } - - // Validate passwords (if provided). - if ($('#password').val() !== $('#retype-password').val()) { - $('#password, #retype-password').addClass('is-invalid'); - throw new Error(App.Lang.passwords_mismatch); - } - - // Validate user email. - if (!GeneralFunctions.validateEmail($('#email').val())) { - $('#email').addClass('is-invalid'); - throw new Error(App.Lang.invalid_email); - } - - if ($('#username').attr('already-exists') === 'true') { - $('#username').addClass('is-invalid'); - throw new Error(App.Lang.username_already_exists); - } - - return true; - } catch (error) { - Backend.displayNotification(error.message); - return false; - } - }; - - window.SystemSettingsCurrentUserHelper = SystemSettingsCurrentUserHelper; -})();