Removed obsolete JS files
This commit is contained in:
parent
e8011afb9a
commit
e0874149b4
2 changed files with 0 additions and 225 deletions
|
@ -1,94 +0,0 @@
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
* Easy!Appointments - Open Source Web Scheduler
|
|
||||||
*
|
|
||||||
* @package EasyAppointments
|
|
||||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
||||||
* @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);
|
|
|
@ -1,131 +0,0 @@
|
||||||
/* ----------------------------------------------------------------------------
|
|
||||||
* Easy!Appointments - Open Source Web Scheduler
|
|
||||||
*
|
|
||||||
* @package EasyAppointments
|
|
||||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
||||||
* @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;
|
|
||||||
})();
|
|
Loading…
Reference in a new issue