mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-29 01:52:24 +03:00
Remove unused users-page scripts
This commit is contained in:
parent
7f4756a6df
commit
547e681a22
4 changed files with 0 additions and 1910 deletions
|
@ -1,236 +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.BackendUsers = window.BackendUsers || {};
|
||||
|
||||
/**
|
||||
* Backend Users
|
||||
*
|
||||
* This module handles the js functionality of the users backend page. It uses three other
|
||||
* classes (defined below) in order to handle the admin, provider and secretary record types.
|
||||
*
|
||||
* @module BackendUsers
|
||||
*/
|
||||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Minimum Password Length
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
exports.MIN_PASSWORD_LENGTH = 7;
|
||||
|
||||
/**
|
||||
* Contains the current tab record methods for the page.
|
||||
*
|
||||
* @type {AdminsHelper|ProvidersHelper|SecretariesHelper}
|
||||
*/
|
||||
var helper = {};
|
||||
|
||||
/**
|
||||
* Use this class instance for performing actions on the working plan.
|
||||
*
|
||||
* @type {WorkingPlan}
|
||||
*/
|
||||
exports.wp = {};
|
||||
|
||||
/**
|
||||
* Initialize the backend users page.
|
||||
*
|
||||
* @param {Boolean} defaultEventHandlers (OPTIONAL) Whether to bind the default event handlers.
|
||||
*/
|
||||
exports.initialize = function (defaultEventHandlers) {
|
||||
defaultEventHandlers = defaultEventHandlers || true;
|
||||
|
||||
exports.wp = new WorkingPlan();
|
||||
exports.wp.bindEventHandlers();
|
||||
|
||||
// Instantiate default helper object (admin).
|
||||
helper = new ProvidersHelper();
|
||||
helper.resetForm();
|
||||
helper.filter('');
|
||||
helper.bindEventHandlers();
|
||||
|
||||
// Fill the services and providers list boxes.
|
||||
GlobalVariables.services.forEach(function (service) {
|
||||
$('<div/>', {
|
||||
'class': 'checkbox',
|
||||
'html': [
|
||||
$('<div/>', {
|
||||
'class': 'checkbox form-check',
|
||||
'html': [
|
||||
$('<input/>', {
|
||||
'class': 'form-check-input',
|
||||
'type': 'checkbox',
|
||||
'data-id': service.id,
|
||||
'prop': {
|
||||
'disabled': true
|
||||
}
|
||||
}),
|
||||
$('<label/>', {
|
||||
'class': 'form-check-label',
|
||||
'text': service.name,
|
||||
'for': service.id
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}).appendTo('#provider-services');
|
||||
});
|
||||
|
||||
GlobalVariables.providers.forEach(function (provider) {
|
||||
$('<div/>', {
|
||||
'class': 'checkbox',
|
||||
'html': [
|
||||
$('<div/>', {
|
||||
'class': 'checkbox form-check',
|
||||
'html': [
|
||||
$('<input/>', {
|
||||
'class': 'form-check-input',
|
||||
'type': 'checkbox',
|
||||
'data-id': provider.id
|
||||
}),
|
||||
$('<label/>', {
|
||||
'class': 'form-check-label',
|
||||
'text': provider.first_name + ' ' + provider.last_name,
|
||||
'for': provider.id
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}).appendTo('#secretary-providers');
|
||||
});
|
||||
|
||||
// Bind event handlers.
|
||||
if (defaultEventHandlers) {
|
||||
bindEventHandlers();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds the default backend users event handlers. Do not use this method on a different
|
||||
* page because it needs the backend users page DOM.
|
||||
*/
|
||||
function bindEventHandlers() {
|
||||
/**
|
||||
* Event: Page Tab Button "Click"
|
||||
*
|
||||
* Changes the displayed tab.
|
||||
*/
|
||||
$('#users-page > .nav-pills a[data-toggle="tab"]').on('shown.bs.tab', function () {
|
||||
if ($(this).parents('.switch-view').length) {
|
||||
return; // Do not proceed if this was the sub navigation.
|
||||
}
|
||||
|
||||
if (helper) {
|
||||
helper.unbindEventHandlers();
|
||||
}
|
||||
|
||||
if ($(this).attr('href') === '#admins') {
|
||||
helper = new AdminsHelper();
|
||||
} else if ($(this).attr('href') === '#providers') {
|
||||
helper = new ProvidersHelper();
|
||||
} else if ($(this).attr('href') === '#secretaries') {
|
||||
helper = new SecretariesHelper();
|
||||
|
||||
// Update the list with the all the available providers.
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
key: ''
|
||||
};
|
||||
|
||||
$.post(url, data).done(function (response) {
|
||||
GlobalVariables.providers = response;
|
||||
|
||||
$('#secretary-providers').empty();
|
||||
|
||||
GlobalVariables.providers.forEach(function (provider) {
|
||||
$('<div/>', {
|
||||
'class': 'checkbox',
|
||||
'html': [
|
||||
$('<div/>', {
|
||||
'class': 'checkbox form-check',
|
||||
'html': [
|
||||
$('<input/>', {
|
||||
'class': 'form-check-input',
|
||||
'type': 'checkbox',
|
||||
'data-id': provider.id,
|
||||
'prop': {
|
||||
'disabled': true
|
||||
}
|
||||
}),
|
||||
$('<label/>', {
|
||||
'class': 'form-check-label',
|
||||
'text': provider.first_name + ' ' + provider.last_name,
|
||||
'for': provider.id
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}).appendTo('#secretary-providers');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
helper.resetForm();
|
||||
helper.filter('');
|
||||
helper.bindEventHandlers();
|
||||
$('.filter-key').val('');
|
||||
Backend.placeFooterToBottom();
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Admin, Provider, Secretary Username "Focusout"
|
||||
*
|
||||
* When the user leaves the username input field we will need to check if the username
|
||||
* is not taken by another record in the system. Usernames must be unique.
|
||||
*/
|
||||
$('#admin-username, #provider-username, #secretary-username').focusout(function () {
|
||||
var $input = $(this);
|
||||
|
||||
if ($input.prop('readonly') === true || $input.val() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
var userId = $input.parents().eq(2).find('.record-id').val();
|
||||
|
||||
if (!userId) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
username: $input.val(),
|
||||
user_id: userId
|
||||
};
|
||||
|
||||
$.post(url, data).done(function (response) {
|
||||
if (response.is_valid === 'false') {
|
||||
$input.addClass('is-invalid');
|
||||
$input.attr('already-exists', 'true');
|
||||
$input.parents().eq(3).find('.form-message').text(App.Lang.username_already_exists);
|
||||
$input.parents().eq(3).find('.form-message').show();
|
||||
} else {
|
||||
$input.removeClass('is-invalid');
|
||||
$input.attr('already-exists', 'false');
|
||||
if ($input.parents().eq(3).find('.form-message').text() === App.Lang.username_already_exists) {
|
||||
$input.parents().eq(3).find('.form-message').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})(window.BackendUsers);
|
|
@ -1,488 +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';
|
||||
|
||||
/**
|
||||
* This class contains the Admins helper class declaration, along with the "Admins" tab
|
||||
* event handlers. By dividing the backend/users tab functionality into separate files
|
||||
* it is easier to maintain the code.
|
||||
*
|
||||
* @class AdminsHelper
|
||||
*/
|
||||
var AdminsHelper = function () {
|
||||
this.filterResults = []; // Store the results for later use.
|
||||
this.filterLimit = 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind the event handlers for the backend/users "Admins" tab.
|
||||
*/
|
||||
AdminsHelper.prototype.bindEventHandlers = function () {
|
||||
/**
|
||||
* Event: Filter Admins Form "Submit"
|
||||
*
|
||||
* Filter the admin records with the given key string.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
$('#admins').on(
|
||||
'submit',
|
||||
'#filter-admins form',
|
||||
function (event) {
|
||||
event.preventDefault();
|
||||
var key = $('#filter-admins .key').val();
|
||||
$('#filter-admins .selected').removeClass('selected');
|
||||
this.resetForm();
|
||||
this.filter(key);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Clear Filter Results Button "Click"
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'#filter-admins .clear',
|
||||
function () {
|
||||
this.filter('');
|
||||
$('#filter-admins .key').val('');
|
||||
this.resetForm();
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Filter Admin Row "Click"
|
||||
*
|
||||
* Display the selected admin data to the user.
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'.admin-row',
|
||||
function (event) {
|
||||
if ($('#filter-admins .filter').prop('disabled')) {
|
||||
$('#filter-admins .results').css('color', '#AAA');
|
||||
return; // exit because we are currently on edit mode
|
||||
}
|
||||
|
||||
var adminId = $(event.currentTarget).attr('data-id');
|
||||
|
||||
var admin = this.filterResults.find(function (filterResult) {
|
||||
return Number(filterResult.id) === Number(adminId);
|
||||
});
|
||||
|
||||
this.display(admin);
|
||||
$('#filter-admins .selected').removeClass('selected');
|
||||
$(event.currentTarget).addClass('selected');
|
||||
$('#edit-admin, #delete-admin').prop('disabled', false);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Add New Admin Button "Click"
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'#add-admin',
|
||||
function () {
|
||||
this.resetForm();
|
||||
$('#admins .add-edit-delete-group').hide();
|
||||
$('#admins .save-cancel-group').show();
|
||||
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#admins .record-details').find('select').prop('disabled', false);
|
||||
$('#admin-password, #admin-password-confirm').addClass('required');
|
||||
$('#filter-admins button').prop('disabled', true);
|
||||
$('#filter-admins .results').css('color', '#AAA');
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Edit Admin Button "Click"
|
||||
*/
|
||||
$('#admins').on('click', '#edit-admin', function () {
|
||||
$('#admins .add-edit-delete-group').hide();
|
||||
$('#admins .save-cancel-group').show();
|
||||
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#admins .record-details').find('select').prop('disabled', false);
|
||||
$('#admin-password, #admin-password-confirm').removeClass('required');
|
||||
$('#filter-admins button').prop('disabled', true);
|
||||
$('#filter-admins .results').css('color', '#AAA');
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Delete Admin Button "Click"
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'#delete-admin',
|
||||
function () {
|
||||
var adminId = $('#admin-id').val();
|
||||
|
||||
var buttons = [
|
||||
{
|
||||
text: App.Lang.cancel,
|
||||
click: function () {
|
||||
$('#message-box').dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: App.Lang.delete,
|
||||
click: function () {
|
||||
this.delete(adminId);
|
||||
$('#message-box').dialog('close');
|
||||
}.bind(this)
|
||||
}
|
||||
];
|
||||
|
||||
GeneralFunctions.displayMessageBox(App.Lang.delete_admin, App.Lang.delete_record_prompt, buttons);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Save Admin Button "Click"
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'#save-admin',
|
||||
function () {
|
||||
var admin = {
|
||||
first_name: $('#admin-first-name').val(),
|
||||
last_name: $('#admin-last-name').val(),
|
||||
email: $('#admin-email').val(),
|
||||
mobile_number: $('#admin-mobile-number').val(),
|
||||
phone_number: $('#admin-phone-number').val(),
|
||||
address: $('#admin-address').val(),
|
||||
city: $('#admin-city').val(),
|
||||
state: $('#admin-state').val(),
|
||||
zip_code: $('#admin-zip-code').val(),
|
||||
notes: $('#admin-notes').val(),
|
||||
timezone: $('#admin-timezone').val(),
|
||||
settings: {
|
||||
username: $('#admin-username').val(),
|
||||
notifications: $('#admin-notifications').prop('checked'),
|
||||
calendar_view: $('#admin-calendar-view').val()
|
||||
}
|
||||
};
|
||||
|
||||
// Include password if changed.
|
||||
if ($('#admin-password').val() !== '') {
|
||||
admin.settings.password = $('#admin-password').val();
|
||||
}
|
||||
|
||||
// Include id if changed.
|
||||
if ($('#admin-id').val() !== '') {
|
||||
admin.id = $('#admin-id').val();
|
||||
}
|
||||
|
||||
if (!this.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.save(admin);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Cancel Admin Button "Click"
|
||||
*
|
||||
* Cancel add or edit of an admin record.
|
||||
*/
|
||||
$('#admins').on(
|
||||
'click',
|
||||
'#cancel-admin',
|
||||
function () {
|
||||
var id = $('#admin-id').val();
|
||||
this.resetForm();
|
||||
if (id) {
|
||||
this.select(id, true);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the previously registered event handlers.
|
||||
*/
|
||||
AdminsHelper.prototype.unbindEventHandlers = function () {
|
||||
$('#admins')
|
||||
.off('submit', '#filter-admins form')
|
||||
.off('click', '#filter-admins .clear')
|
||||
.off('click', '.admin-row')
|
||||
.off('click', '#add-admin')
|
||||
.off('click', '#edit-admin')
|
||||
.off('click', '#delete-admin')
|
||||
.off('click', '#save-admin')
|
||||
.off('click', '#cancel-admin');
|
||||
};
|
||||
|
||||
/**
|
||||
* Save admin record to database.
|
||||
*
|
||||
* @param {Object} admin Contains the admin record data. If an 'id' value is provided
|
||||
* then the update operation is going to be executed.
|
||||
*/
|
||||
AdminsHelper.prototype.save = function (admin) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_admin';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
admin: JSON.stringify(admin)
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
Backend.displayNotification(App.Lang.admin_saved);
|
||||
this.resetForm();
|
||||
$('#filter-admins .key').val('');
|
||||
this.filter('', response.id, true);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete an admin record from database.
|
||||
*
|
||||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
AdminsHelper.prototype.delete = function (id) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_admin';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
admin_id: id
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
Backend.displayNotification(App.Lang.admin_deleted);
|
||||
this.resetForm();
|
||||
this.filter($('#filter-admins .key').val());
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates an admin record.
|
||||
*
|
||||
* @return {Boolean} Returns the validation result.
|
||||
*/
|
||||
AdminsHelper.prototype.validate = function () {
|
||||
$('#admins .is-invalid').removeClass('is-invalid');
|
||||
|
||||
try {
|
||||
// Validate required fields.
|
||||
var missingRequired = false;
|
||||
|
||||
$('#admins .required').each(function (index, requiredField) {
|
||||
if (!$(requiredField).val()) {
|
||||
$(requiredField).addClass('is-invalid');
|
||||
missingRequired = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (missingRequired) {
|
||||
throw new Error('Fields with * are required.');
|
||||
}
|
||||
|
||||
// Validate passwords.
|
||||
if ($('#admin-password').val() !== $('#admin-password-confirm').val()) {
|
||||
$('#admin-password, #admin-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.passwords_mismatch);
|
||||
}
|
||||
|
||||
if (
|
||||
$('#admin-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH &&
|
||||
$('#admin-password').val() !== ''
|
||||
) {
|
||||
$('#admin-password, #admin-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH));
|
||||
}
|
||||
|
||||
// Validate user email.
|
||||
if (!GeneralFunctions.validateEmail($('#admin-email').val())) {
|
||||
$('#admin-email').addClass('is-invalid');
|
||||
throw new Error(App.Lang.invalid_email);
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($('#admin-username').attr('already-exists') === 'true') {
|
||||
$('#admin-username').addClass('is-invalid');
|
||||
throw new Error(App.Lang.username_already_exists);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
$('#admins .form-message').addClass('alert-danger').text(error.message).show();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the admin form back to its initial state.
|
||||
*/
|
||||
AdminsHelper.prototype.resetForm = function () {
|
||||
$('#filter-admins .selected').removeClass('selected');
|
||||
$('#filter-admins button').prop('disabled', false);
|
||||
$('#filter-admins .results').css('color', '');
|
||||
|
||||
$('#admins .add-edit-delete-group').show();
|
||||
$('#admins .save-cancel-group').hide();
|
||||
$('#admins .record-details').find('input, select, textarea').val('').prop('disabled', true);
|
||||
$('#admins .record-details #admin-calendar-view').val('default');
|
||||
$('#admins .record-details #admin-timezone').val('UTC');
|
||||
$('#edit-admin, #delete-admin').prop('disabled', true);
|
||||
|
||||
$('#admins .is-invalid').removeClass('is-invalid');
|
||||
$('#admins .form-message').hide();
|
||||
};
|
||||
|
||||
/**
|
||||
* Display a admin record into the admin form.
|
||||
*
|
||||
* @param {Object} admin Contains the admin record data.
|
||||
*/
|
||||
AdminsHelper.prototype.display = function (admin) {
|
||||
$('#admin-id').val(admin.id);
|
||||
$('#admin-first-name').val(admin.first_name);
|
||||
$('#admin-last-name').val(admin.last_name);
|
||||
$('#admin-email').val(admin.email);
|
||||
$('#admin-mobile-number').val(admin.mobile_number);
|
||||
$('#admin-phone-number').val(admin.phone_number);
|
||||
$('#admin-address').val(admin.address);
|
||||
$('#admin-city').val(admin.city);
|
||||
$('#admin-state').val(admin.state);
|
||||
$('#admin-zip-code').val(admin.zip_code);
|
||||
$('#admin-notes').val(admin.notes);
|
||||
$('#admin-timezone').val(admin.timezone);
|
||||
|
||||
$('#admin-username').val(admin.settings.username);
|
||||
$('#admin-calendar-view').val(admin.settings.calendar_view);
|
||||
$('#admin-notifications').prop('checked', Boolean(Number(admin.settings.notifications)));
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters admin records depending a key string.
|
||||
*
|
||||
* @param {String} key This string is used to filter the admin records of the database.
|
||||
* @param {Number} selectId (OPTIONAL = undefined) This record id will be selected when
|
||||
* the filter operation is finished.
|
||||
* @param {Boolean} display (OPTIONAL = false) If true the selected record data are going
|
||||
* to be displayed on the details column (requires a selected record though).
|
||||
*/
|
||||
AdminsHelper.prototype.filter = function (key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_admins';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
key: key,
|
||||
limit: this.filterLimit
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
this.filterResults = response;
|
||||
|
||||
$('#filter-admins .results').empty();
|
||||
|
||||
response.forEach(
|
||||
function (admin) {
|
||||
$('#filter-admins .results').append(this.getFilterHtml(admin)).append($('<hr/>'));
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
if (!response.length) {
|
||||
$('#filter-admins .results').append(
|
||||
$('<em/>', {
|
||||
'text': App.Lang.no_records_found
|
||||
})
|
||||
);
|
||||
} else if (response.length === this.filterLimit) {
|
||||
$('<button/>', {
|
||||
'type': 'button',
|
||||
'class': 'btn btn-outline-secondary w-100 load-more text-center',
|
||||
'text': App.Lang.load_more,
|
||||
'click': function () {
|
||||
this.filterLimit += 20;
|
||||
this.filter(key, selectId, display);
|
||||
}.bind(this)
|
||||
}).appendTo('#filter-admins .results');
|
||||
}
|
||||
|
||||
if (selectId) {
|
||||
this.select(selectId, display);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an admin row html code that is going to be displayed on the filter results list.
|
||||
*
|
||||
* @param {Object} admin Contains the admin record data.
|
||||
*
|
||||
* @return {String} The html code that represents the record on the filter results list.
|
||||
*/
|
||||
AdminsHelper.prototype.getFilterHtml = function (admin) {
|
||||
var name = admin.first_name + ' ' + admin.last_name;
|
||||
|
||||
var info = admin.email;
|
||||
|
||||
info = admin.mobile_number ? info + ', ' + admin.mobile_number : info;
|
||||
|
||||
info = admin.phone_number ? info + ', ' + admin.phone_number : info;
|
||||
|
||||
return $('<div/>', {
|
||||
'class': 'admin-row entry',
|
||||
'data-id': admin.id,
|
||||
'html': [
|
||||
$('<strong/>', {
|
||||
'text': name
|
||||
}),
|
||||
$('<br/>'),
|
||||
$('<span/>', {
|
||||
'text': info
|
||||
}),
|
||||
$('<br/>')
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Select a specific record from the current filter results. If the admin id does not exist
|
||||
* in the list then no record will be selected.
|
||||
*
|
||||
* @param {Number} id The record id to be selected from the filter results.
|
||||
* @param {Boolean} display Optional (false), if true then the method will display the record
|
||||
* on the form.
|
||||
*/
|
||||
AdminsHelper.prototype.select = function (id, display) {
|
||||
display = display || false;
|
||||
|
||||
$('#filter-admins .selected').removeClass('selected');
|
||||
|
||||
$('#filter-admins .admin-row[data-id="' + id + '"]').addClass('selected');
|
||||
|
||||
if (display) {
|
||||
var admin = this.filterResults.find(function (filterResult) {
|
||||
return Number(filterResult.id) === Number(id);
|
||||
});
|
||||
|
||||
this.display(admin);
|
||||
|
||||
$('#edit-admin, #delete-admin').prop('disabled', false);
|
||||
}
|
||||
};
|
||||
|
||||
window.AdminsHelper = AdminsHelper;
|
||||
})();
|
|
@ -1,674 +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';
|
||||
|
||||
/**
|
||||
* Providers Helper
|
||||
*
|
||||
* This class contains the Providers helper class declaration, along with the "Providers" tab
|
||||
* event handlers. By dividing the backend/users tab functionality into separate files
|
||||
* it is easier to maintain the code.
|
||||
*
|
||||
* @class ProvidersHelper
|
||||
*/
|
||||
var ProvidersHelper = function () {
|
||||
this.filterResults = {}; // Store the results for later use.
|
||||
this.filterLimit = 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind the event handlers for the backend/users "Providers" tab.
|
||||
*/
|
||||
ProvidersHelper.prototype.bindEventHandlers = function () {
|
||||
/**
|
||||
* Event: Filter Providers Form "Submit"
|
||||
*
|
||||
* Filter the provider records with the given key string.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
$('#providers').on(
|
||||
'submit',
|
||||
'#filter-providers form',
|
||||
function (event) {
|
||||
event.preventDefault();
|
||||
var key = $('#filter-providers .key').val();
|
||||
$('.selected').removeClass('selected');
|
||||
this.resetForm();
|
||||
this.filter(key);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Clear Filter Button "Click"
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'#filter-providers .clear',
|
||||
function () {
|
||||
this.filter('');
|
||||
$('#filter-providers .key').val('');
|
||||
this.resetForm();
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Filter Provider Row "Click"
|
||||
*
|
||||
* Display the selected provider data to the user.
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'.provider-row',
|
||||
function (event) {
|
||||
if ($('#filter-providers .filter').prop('disabled')) {
|
||||
$('#filter-providers .results').css('color', '#AAA');
|
||||
return; // Exit because we are currently on edit mode.
|
||||
}
|
||||
|
||||
var providerId = $(event.currentTarget).attr('data-id');
|
||||
var provider = this.filterResults.find(function (filterResult) {
|
||||
return Number(filterResult.id) === Number(providerId);
|
||||
});
|
||||
|
||||
this.display(provider);
|
||||
$('#filter-providers .selected').removeClass('selected');
|
||||
$(event.currentTarget).addClass('selected');
|
||||
$('#edit-provider, #delete-provider').prop('disabled', false);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Add New Provider Button "Click"
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'#add-provider',
|
||||
function () {
|
||||
this.resetForm();
|
||||
$('#filter-providers button').prop('disabled', true);
|
||||
$('#filter-providers .results').css('color', '#AAA');
|
||||
$('#providers .add-edit-delete-group').hide();
|
||||
$('#providers .save-cancel-group').show();
|
||||
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
|
||||
$('#provider-password, #provider-password-confirm').addClass('required');
|
||||
$('#providers')
|
||||
.find(
|
||||
'.add-break, .edit-break, .delete-break, .add-working-plan-exception, .edit-working-plan-exception, .delete-working-plan-exception, #reset-working-plan'
|
||||
)
|
||||
.prop('disabled', false);
|
||||
$('#provider-services input:checkbox').prop('disabled', false);
|
||||
|
||||
// Apply default working plan
|
||||
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
||||
BackendUsers.wp.timepickers(false);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Edit Provider Button "Click"
|
||||
*/
|
||||
$('#providers').on('click', '#edit-provider', function () {
|
||||
$('#providers .add-edit-delete-group').hide();
|
||||
$('#providers .save-cancel-group').show();
|
||||
$('#filter-providers button').prop('disabled', true);
|
||||
$('#filter-providers .results').css('color', '#AAA');
|
||||
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
|
||||
$('#provider-password, #provider-password-confirm').removeClass('required');
|
||||
$('#provider-services input:checkbox').prop('disabled', false);
|
||||
$('#providers')
|
||||
.find(
|
||||
'.add-break, .edit-break, .delete-break, .add-working-plan-exception, .edit-working-plan-exception, .delete-working-plan-exception, #reset-working-plan'
|
||||
)
|
||||
.prop('disabled', false);
|
||||
$('#providers input:checkbox').prop('disabled', false);
|
||||
BackendUsers.wp.timepickers(false);
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Delete Provider Button "Click"
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'#delete-provider',
|
||||
function () {
|
||||
var providerId = $('#provider-id').val();
|
||||
|
||||
var buttons = [
|
||||
{
|
||||
text: App.Lang.cancel,
|
||||
click: function () {
|
||||
$('#message-box').dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: App.Lang.delete,
|
||||
click: function () {
|
||||
this.delete(providerId);
|
||||
$('#message-box').dialog('close');
|
||||
}.bind(this)
|
||||
}
|
||||
];
|
||||
|
||||
GeneralFunctions.displayMessageBox(App.Lang.delete_provider, App.Lang.delete_record_prompt, buttons);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Save Provider Button "Click"
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'#save-provider',
|
||||
function () {
|
||||
var provider = {
|
||||
first_name: $('#provider-first-name').val(),
|
||||
last_name: $('#provider-last-name').val(),
|
||||
email: $('#provider-email').val(),
|
||||
mobile_number: $('#provider-mobile-number').val(),
|
||||
phone_number: $('#provider-phone-number').val(),
|
||||
address: $('#provider-address').val(),
|
||||
city: $('#provider-city').val(),
|
||||
state: $('#provider-state').val(),
|
||||
zip_code: $('#provider-zip-code').val(),
|
||||
notes: $('#provider-notes').val(),
|
||||
timezone: $('#provider-timezone').val(),
|
||||
settings: {
|
||||
username: $('#provider-username').val(),
|
||||
working_plan: JSON.stringify(BackendUsers.wp.get()),
|
||||
working_plan_exceptions: JSON.stringify(BackendUsers.wp.getWorkingPlanExceptions()),
|
||||
notifications: $('#provider-notifications').prop('checked'),
|
||||
calendar_view: $('#provider-calendar-view').val()
|
||||
}
|
||||
};
|
||||
|
||||
// Include provider services.
|
||||
provider.services = [];
|
||||
$('#provider-services input:checkbox').each(function (index, checkbox) {
|
||||
if ($(checkbox).prop('checked')) {
|
||||
provider.services.push($(checkbox).attr('data-id'));
|
||||
}
|
||||
});
|
||||
|
||||
// Include password if changed.
|
||||
if ($('#provider-password').val() !== '') {
|
||||
provider.settings.password = $('#provider-password').val();
|
||||
}
|
||||
|
||||
// Include id if changed.
|
||||
if ($('#provider-id').val() !== '') {
|
||||
provider.id = $('#provider-id').val();
|
||||
}
|
||||
|
||||
if (!this.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.save(provider);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Cancel Provider Button "Click"
|
||||
*
|
||||
* Cancel add or edit of an provider record.
|
||||
*/
|
||||
$('#providers').on(
|
||||
'click',
|
||||
'#cancel-provider',
|
||||
function () {
|
||||
var id = $('#filter-providers .selected').attr('data-id');
|
||||
this.resetForm();
|
||||
if (id) {
|
||||
this.select(id, true);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Display Provider Details "Click"
|
||||
*/
|
||||
$('#providers').on('shown.bs.tab', 'a[data-toggle="tab"]', function () {
|
||||
Backend.placeFooterToBottom();
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Reset Working Plan Button "Click".
|
||||
*/
|
||||
$('#providers').on('click', '#reset-working-plan', function () {
|
||||
$('.breaks tbody').empty();
|
||||
$('.working-plan-exceptions tbody').empty();
|
||||
$('.work-start, .work-end').val('');
|
||||
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
||||
BackendUsers.wp.timepickers(false);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the previously registered event handlers.
|
||||
*/
|
||||
ProvidersHelper.prototype.unbindEventHandlers = function () {
|
||||
$('#providers')
|
||||
.off('submit', '#filter-providers form')
|
||||
.off('click', '#filter-providers .clear')
|
||||
.off('click', '.provider-row')
|
||||
.off('click', '#add-provider')
|
||||
.off('click', '#edit-provider')
|
||||
.off('click', '#delete-provider')
|
||||
.off('click', '#save-provider')
|
||||
.off('click', '#cancel-provider')
|
||||
.off('shown.bs.tab', 'a[data-toggle="tab"]')
|
||||
.off('click', '#reset-working-plan');
|
||||
};
|
||||
|
||||
/**
|
||||
* Save provider record to database.
|
||||
*
|
||||
* @param {Object} provider Contains the admin record data. If an 'id' value is provided
|
||||
* then the update operation is going to be executed.
|
||||
*/
|
||||
ProvidersHelper.prototype.save = function (provider) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_provider';
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
provider: JSON.stringify(provider)
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
Backend.displayNotification(App.Lang.provider_saved);
|
||||
this.resetForm();
|
||||
$('#filter-providers .key').val('');
|
||||
this.filter('', response.id, true);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a provider record from database.
|
||||
*
|
||||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
ProvidersHelper.prototype.delete = function (id) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_provider';
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
provider_id: id
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function () {
|
||||
Backend.displayNotification(App.Lang.provider_deleted);
|
||||
this.resetForm();
|
||||
this.filter($('#filter-providers .key').val());
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates a provider record.
|
||||
*
|
||||
* @return {Boolean} Returns the validation result.
|
||||
*/
|
||||
ProvidersHelper.prototype.validate = function () {
|
||||
$('#providers .is-invalid').removeClass('is-invalid');
|
||||
$('#providers .form-message').removeClass('alert-danger').hide();
|
||||
|
||||
try {
|
||||
// Validate required fields.
|
||||
var missingRequired = false;
|
||||
$('#providers .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 ($('#provider-password').val() !== $('#provider-password-confirm').val()) {
|
||||
$('#provider-password, #provider-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.passwords_mismatch);
|
||||
}
|
||||
|
||||
if (
|
||||
$('#provider-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH &&
|
||||
$('#provider-password').val() !== ''
|
||||
) {
|
||||
$('#provider-password, #provider-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH));
|
||||
}
|
||||
|
||||
// Validate user email.
|
||||
if (!GeneralFunctions.validateEmail($('#provider-email').val())) {
|
||||
$('#provider-email').addClass('is-invalid');
|
||||
throw new Error(App.Lang.invalid_email);
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($('#provider-username').attr('already-exists') === 'true') {
|
||||
$('#provider-username').addClass('is-invalid');
|
||||
throw new Error(App.Lang.username_already_exists);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
$('#providers .form-message').addClass('alert-danger').text(error.message).show();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the admin tab form back to its initial state.
|
||||
*/
|
||||
ProvidersHelper.prototype.resetForm = function () {
|
||||
$('#filter-providers .selected').removeClass('selected');
|
||||
$('#filter-providers button').prop('disabled', false);
|
||||
$('#filter-providers .results').css('color', '');
|
||||
|
||||
$('#providers .add-edit-delete-group').show();
|
||||
$('#providers .save-cancel-group').hide();
|
||||
$('#providers .record-details h3 a').remove();
|
||||
$('#providers .record-details').find('input, select, textarea').val('').prop('disabled', true);
|
||||
$('#providers .record-details #provider-calendar-view').val('default');
|
||||
$('#providers .record-details #provider-timezone').val('UTC');
|
||||
$('#providers .add-break, .add-working-plan-exception, #reset-working-plan').prop('disabled', true);
|
||||
BackendUsers.wp.timepickers(true);
|
||||
$('#providers .working-plan input:text').timepicker('destroy');
|
||||
$('#providers .working-plan input:checkbox').prop('disabled', true);
|
||||
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
||||
$('.working-plan-exceptions')
|
||||
.find('.edit-working-plan-exception, .delete-working-plan-exception')
|
||||
.prop('disabled', true);
|
||||
|
||||
$('#providers .record-details .is-invalid').removeClass('is-invalid');
|
||||
$('#providers .record-details .form-message').hide();
|
||||
|
||||
$('#edit-provider, #delete-provider').prop('disabled', true);
|
||||
$('#provider-services input:checkbox').prop('disabled', true).prop('checked', false);
|
||||
$('#provider-services a').remove();
|
||||
$('#providers .working-plan tbody').empty();
|
||||
$('#providers .breaks tbody').empty();
|
||||
$('#providers .working-plan-exceptions tbody').empty();
|
||||
};
|
||||
|
||||
/**
|
||||
* Display a provider record into the admin form.
|
||||
*
|
||||
* @param {Object} provider Contains the provider record data.
|
||||
*/
|
||||
ProvidersHelper.prototype.display = function (provider) {
|
||||
$('#provider-id').val(provider.id);
|
||||
$('#provider-first-name').val(provider.first_name);
|
||||
$('#provider-last-name').val(provider.last_name);
|
||||
$('#provider-email').val(provider.email);
|
||||
$('#provider-mobile-number').val(provider.mobile_number);
|
||||
$('#provider-phone-number').val(provider.phone_number);
|
||||
$('#provider-address').val(provider.address);
|
||||
$('#provider-city').val(provider.city);
|
||||
$('#provider-state').val(provider.state);
|
||||
$('#provider-zip-code').val(provider.zip_code);
|
||||
$('#provider-notes').val(provider.notes);
|
||||
$('#provider-timezone').val(provider.timezone);
|
||||
|
||||
$('#provider-username').val(provider.settings.username);
|
||||
$('#provider-calendar-view').val(provider.settings.calendar_view);
|
||||
$('#provider-notifications').prop('checked', Boolean(Number(provider.settings.notifications)));
|
||||
|
||||
// Add dedicated provider link.
|
||||
var dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id);
|
||||
var $link = $('<a/>', {
|
||||
'href': dedicatedUrl,
|
||||
'html': [
|
||||
$('<span/>', {
|
||||
'class': 'fas fa-link'
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
$('#providers .details-view h3').find('a').remove().end().append($link);
|
||||
|
||||
$('#provider-services a').remove();
|
||||
$('#provider-services input:checkbox').prop('checked', false);
|
||||
|
||||
provider.services.forEach(function (providerServiceId) {
|
||||
var $checkbox = $('#provider-services input[data-id="' + providerServiceId + '"]');
|
||||
|
||||
if (!$checkbox.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkbox.prop('checked', true);
|
||||
|
||||
// Add dedicated service-provider link.
|
||||
dedicatedUrl =
|
||||
GlobalVariables.baseUrl +
|
||||
'/index.php?provider=' +
|
||||
encodeURIComponent(provider.id) +
|
||||
'&service=' +
|
||||
encodeURIComponent(providerServiceId);
|
||||
|
||||
$link = $('<a/>', {
|
||||
'href': dedicatedUrl,
|
||||
'html': [
|
||||
$('<span/>', {
|
||||
'class': 'fas fa-link'
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
$checkbox.parent().append($link);
|
||||
});
|
||||
|
||||
// Display working plan
|
||||
var workingPlan = $.parseJSON(provider.settings.working_plan);
|
||||
BackendUsers.wp.setup(workingPlan);
|
||||
$('.working-plan').find('input').prop('disabled', true);
|
||||
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
||||
$('#providers .working-plan-exceptions tbody').empty();
|
||||
var workingPlanExceptions = $.parseJSON(provider.settings.working_plan_exceptions);
|
||||
BackendUsers.wp.setupWorkingPlanExceptions(workingPlanExceptions);
|
||||
$('.working-plan-exceptions')
|
||||
.find('.edit-working-plan-exception, .delete-working-plan-exception')
|
||||
.prop('disabled', true);
|
||||
$('#providers .working-plan input:checkbox').prop('disabled', true);
|
||||
Backend.placeFooterToBottom();
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters provider records depending a string key.
|
||||
*
|
||||
* @param {string} key This is used to filter the provider records of the database.
|
||||
* @param {numeric} selectId Optional, if set, when the function is complete a result row can be set as selected.
|
||||
* @param {bool} display Optional (false), if true the selected record will be also displayed.
|
||||
*/
|
||||
ProvidersHelper.prototype.filter = function (key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
key: key,
|
||||
limit: this.filterLimit
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
this.filterResults = response;
|
||||
|
||||
$('#filter-providers .results').empty();
|
||||
response.forEach(
|
||||
function (provider) {
|
||||
$('#filter-providers .results').append(this.getFilterHtml(provider)).append($('<hr/>'));
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
if (!response.length) {
|
||||
$('#filter-providers .results').append(
|
||||
$('<em/>', {
|
||||
'text': App.Lang.no_records_found
|
||||
})
|
||||
);
|
||||
} else if (response.length === this.filterLimit) {
|
||||
$('<button/>', {
|
||||
'type': 'button',
|
||||
'class': 'btn btn-outline-secondary w-100 load-more text-center',
|
||||
'text': App.Lang.load_more,
|
||||
'click': function () {
|
||||
this.filterLimit += 20;
|
||||
this.filter(key, selectId, display);
|
||||
}.bind(this)
|
||||
}).appendTo('#filter-providers .results');
|
||||
}
|
||||
|
||||
if (selectId) {
|
||||
this.select(selectId, display);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an provider row html code that is going to be displayed on the filter results list.
|
||||
*
|
||||
* @param {Object} provider Contains the provider record data.
|
||||
*
|
||||
* @return {String} The html code that represents the record on the filter results list.
|
||||
*/
|
||||
ProvidersHelper.prototype.getFilterHtml = function (provider) {
|
||||
var name = provider.first_name + ' ' + provider.last_name;
|
||||
|
||||
var info = provider.email;
|
||||
|
||||
info = provider.mobile_number ? info + ', ' + provider.mobile_number : info;
|
||||
|
||||
info = provider.phone_number ? info + ', ' + provider.phone_number : info;
|
||||
|
||||
return $('<div/>', {
|
||||
'class': 'provider-row entry',
|
||||
'data-id': provider.id,
|
||||
'html': [
|
||||
$('<strong/>', {
|
||||
'text': name
|
||||
}),
|
||||
$('<br/>'),
|
||||
$('<span/>', {
|
||||
'text': info
|
||||
}),
|
||||
$('<br/>')
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the editable functionality to the break day table cells.
|
||||
*
|
||||
* @param {Object} $selector The cells to be initialized.
|
||||
*/
|
||||
ProvidersHelper.prototype.editableDayCell = function ($selector) {
|
||||
var weekDays = {};
|
||||
weekDays[App.Lang.monday] = 'Monday';
|
||||
weekDays[App.Lang.tuesday] = 'Tuesday';
|
||||
weekDays[App.Lang.wednesday] = 'Wednesday';
|
||||
weekDays[App.Lang.thursday] = 'Thursday';
|
||||
weekDays[App.Lang.friday] = 'Friday';
|
||||
weekDays[App.Lang.saturday] = 'Saturday';
|
||||
weekDays[App.Lang.sunday] = 'Sunday';
|
||||
|
||||
$selector.editable(
|
||||
function (value, settings) {
|
||||
return value;
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
data: weekDays,
|
||||
event: 'edit',
|
||||
height: '30px',
|
||||
submit: '<button type="button" class="d-none submit-editable">Submit</button>',
|
||||
cancel: '<button type="button" class="d-none cancel-editable">Cancel</button>',
|
||||
onblur: 'ignore',
|
||||
onreset: function (settings, td) {
|
||||
if (!BackendUsers.enableCancel) {
|
||||
return false; // disable ESC button
|
||||
}
|
||||
},
|
||||
onsubmit: function (settings, td) {
|
||||
if (!BackendUsers.enableSubmit) {
|
||||
return false; // disable Enter button
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the editable functionality to the break time table cells.
|
||||
*
|
||||
* @param {jQuery} $selector The cells to be initialized.
|
||||
*/
|
||||
ProvidersHelper.prototype.editableTimeCell = function ($selector) {
|
||||
$selector.editable(
|
||||
function (value, settings) {
|
||||
// Do not return the value because the user needs to press the "Save" button.
|
||||
return value;
|
||||
},
|
||||
{
|
||||
event: 'edit',
|
||||
height: '25px',
|
||||
submit: '<button type="button" class="d-none submit-editable">Submit</button>',
|
||||
cancel: '<button type="button" class="d-none cancel-editable">Cancel</button>',
|
||||
onblur: 'ignore',
|
||||
onreset: function (settings, td) {
|
||||
if (!BackendUsers.enableCancel) {
|
||||
return false; // disable ESC button
|
||||
}
|
||||
},
|
||||
onsubmit: function (settings, td) {
|
||||
if (!BackendUsers.enableSubmit) {
|
||||
return false; // disable Enter button
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Select and display a providers filter result on the form.
|
||||
*
|
||||
* @param {Number} id Record id to be selected.
|
||||
* @param {Boolean} display Optional (false), if true the record will be displayed on the form.
|
||||
*/
|
||||
ProvidersHelper.prototype.select = function (id, display) {
|
||||
display = display || false;
|
||||
|
||||
// Select record in filter results.
|
||||
$('#filter-providers .provider-row[data-id="' + id + '"]').addClass('selected');
|
||||
|
||||
// Display record in form (if display = true).
|
||||
if (display) {
|
||||
var provider = this.filterResults.find(
|
||||
function (filterResult) {
|
||||
return Number(filterResult.id) === Number(id);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.display(provider);
|
||||
|
||||
$('#edit-provider, #delete-provider').prop('disabled', false);
|
||||
}
|
||||
};
|
||||
|
||||
window.ProvidersHelper = ProvidersHelper;
|
||||
})();
|
|
@ -1,512 +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';
|
||||
|
||||
/**
|
||||
* Secretaries Helper
|
||||
*
|
||||
* This class contains the Secretaries helper class declaration, along with the "Secretaries"
|
||||
* tab event handlers. By dividing the backend/users tab functionality into separate files
|
||||
* it is easier to maintain the code.
|
||||
*
|
||||
* @class SecretariesHelper
|
||||
*/
|
||||
var SecretariesHelper = function () {
|
||||
this.filterResults = {}; // Store the results for later use.
|
||||
this.filterLimit = 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind the event handlers for the backend/users "Secretaries" tab.
|
||||
*/
|
||||
SecretariesHelper.prototype.bindEventHandlers = function () {
|
||||
/**
|
||||
* Event: Filter Secretaries Form "Submit"
|
||||
*
|
||||
* Filter the secretary records with the given key string.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'submit',
|
||||
'#filter-secretaries form',
|
||||
function (event) {
|
||||
event.preventDefault();
|
||||
var key = $('#filter-secretaries .key').val();
|
||||
$('#filter-secretaries .selected').removeClass('selected');
|
||||
this.resetForm();
|
||||
this.filter(key);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Clear Filter Results Button "Click"
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'#filter-secretaries .clear',
|
||||
function () {
|
||||
this.filter('');
|
||||
$('#filter-secretaries .key').val('');
|
||||
this.resetForm();
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Filter Secretary Row "Click"
|
||||
*
|
||||
* Display the selected secretary data to the user.
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'.secretary-row',
|
||||
function (event) {
|
||||
if ($('#filter-secretaries .filter').prop('disabled')) {
|
||||
$('#filter-secretaries .results').css('color', '#AAA');
|
||||
return; // exit because we are currently on edit mode
|
||||
}
|
||||
|
||||
var secretaryId = $(event.currentTarget).attr('data-id');
|
||||
|
||||
var secretary = this.filterResults.find(function (filterResult) {
|
||||
return Number(filterResult.id) === Number(secretaryId);
|
||||
});
|
||||
|
||||
this.display(secretary);
|
||||
|
||||
$('#filter-secretaries .selected').removeClass('selected');
|
||||
$(event.currentTarget).addClass('selected');
|
||||
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Add New Secretary Button "Click"
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'#add-secretary',
|
||||
function () {
|
||||
this.resetForm();
|
||||
$('#filter-secretaries button').prop('disabled', true);
|
||||
$('#filter-secretaries .results').css('color', '#AAA');
|
||||
|
||||
$('#secretaries .add-edit-delete-group').hide();
|
||||
$('#secretaries .save-cancel-group').show();
|
||||
$('#secretaries .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#secretaries .record-details').find('select').prop('disabled', false);
|
||||
$('#secretary-password, #secretary-password-confirm').addClass('required');
|
||||
$('#secretary-providers input:checkbox').prop('disabled', false);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Edit Secretary Button "Click"
|
||||
*/
|
||||
$('#secretaries').on('click', '#edit-secretary', function () {
|
||||
$('#filter-secretaries button').prop('disabled', true);
|
||||
$('#filter-secretaries .results').css('color', '#AAA');
|
||||
$('#secretaries .add-edit-delete-group').hide();
|
||||
$('#secretaries .save-cancel-group').show();
|
||||
$('#secretaries .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#secretaries .record-details').find('select').prop('disabled', false);
|
||||
$('#secretary-password, #secretary-password-confirm').removeClass('required');
|
||||
$('#secretary-providers input:checkbox').prop('disabled', false);
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Delete Secretary Button "Click"
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'#delete-secretary',
|
||||
function () {
|
||||
var secretaryId = $('#secretary-id').val();
|
||||
var buttons = [
|
||||
{
|
||||
text: App.Lang.cancel,
|
||||
click: function () {
|
||||
$('#message-box').dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: App.Lang.delete,
|
||||
click: function () {
|
||||
this.delete(secretaryId);
|
||||
$('#message-box').dialog('close');
|
||||
}.bind(this)
|
||||
}
|
||||
];
|
||||
|
||||
GeneralFunctions.displayMessageBox(App.Lang.delete_secretary, App.Lang.delete_record_prompt, buttons);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Save Secretary Button "Click"
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'#save-secretary',
|
||||
function () {
|
||||
var secretary = {
|
||||
first_name: $('#secretary-first-name').val(),
|
||||
last_name: $('#secretary-last-name').val(),
|
||||
email: $('#secretary-email').val(),
|
||||
mobile_number: $('#secretary-mobile-number').val(),
|
||||
phone_number: $('#secretary-phone-number').val(),
|
||||
address: $('#secretary-address').val(),
|
||||
city: $('#secretary-city').val(),
|
||||
state: $('#secretary-state').val(),
|
||||
zip_code: $('#secretary-zip-code').val(),
|
||||
notes: $('#secretary-notes').val(),
|
||||
timezone: $('#secretary-timezone').val(),
|
||||
settings: {
|
||||
username: $('#secretary-username').val(),
|
||||
notifications: $('#secretary-notifications').prop('checked'),
|
||||
calendar_view: $('#secretary-calendar-view').val()
|
||||
}
|
||||
};
|
||||
|
||||
// Include secretary services.
|
||||
secretary.providers = [];
|
||||
$('#secretary-providers input:checkbox').each(function (index, checkbox) {
|
||||
if ($(checkbox).prop('checked')) {
|
||||
secretary.providers.push($(checkbox).attr('data-id'));
|
||||
}
|
||||
});
|
||||
|
||||
// Include password if changed.
|
||||
if ($('#secretary-password').val() !== '') {
|
||||
secretary.settings.password = $('#secretary-password').val();
|
||||
}
|
||||
|
||||
// Include ID if changed.
|
||||
if ($('#secretary-id').val() !== '') {
|
||||
secretary.id = $('#secretary-id').val();
|
||||
}
|
||||
|
||||
if (!this.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.save(secretary);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* Event: Cancel Secretary Button "Click"
|
||||
*
|
||||
* Cancel add or edit of an secretary record.
|
||||
*/
|
||||
$('#secretaries').on(
|
||||
'click',
|
||||
'#cancel-secretary',
|
||||
function () {
|
||||
var id = $('#secretary-id').val();
|
||||
this.resetForm();
|
||||
if (id) {
|
||||
this.select(id, true);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the previously registered event handlers.
|
||||
*/
|
||||
SecretariesHelper.prototype.unbindEventHandlers = function () {
|
||||
$('#secretaries')
|
||||
.off('submit', '#filter-secretaries form')
|
||||
.off('click', '#filter-secretaries .clear')
|
||||
.off('click', '.secretary-row')
|
||||
.off('click', '#add-secretary')
|
||||
.off('click', '#edit-secretary')
|
||||
.off('click', '#delete-secretary')
|
||||
.off('click', '#save-secretary')
|
||||
.off('click', '#cancel-secretary');
|
||||
};
|
||||
|
||||
/**
|
||||
* Save secretary record to database.
|
||||
*
|
||||
* @param {Object} secretary Contains the secretary record data. If an 'id' value is provided
|
||||
* then the update operation is going to be executed.
|
||||
*/
|
||||
SecretariesHelper.prototype.save = function (secretary) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_secretary';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
secretary: JSON.stringify(secretary)
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
Backend.displayNotification(App.Lang.secretary_saved);
|
||||
this.resetForm();
|
||||
$('#filter-secretaries .key').val('');
|
||||
this.filter('', response.id, true);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a secretary record from database.
|
||||
*
|
||||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
SecretariesHelper.prototype.delete = function (id) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_secretary';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
secretary_id: id
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function () {
|
||||
Backend.displayNotification(App.Lang.secretary_deleted);
|
||||
this.resetForm();
|
||||
this.filter($('#filter-secretaries .key').val());
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates a secretary record.
|
||||
*
|
||||
* @return {Boolean} Returns the validation result.
|
||||
*/
|
||||
SecretariesHelper.prototype.validate = function () {
|
||||
$('#secretaries .is-invalid').removeClass('is-invalid');
|
||||
$('#secretaries .form-message').removeClass('alert-danger');
|
||||
|
||||
try {
|
||||
// Validate required fields.
|
||||
var missingRequired = false;
|
||||
$('#secretaries .required').each(function (index, requiredField) {
|
||||
if (!$(requiredField).val()) {
|
||||
$(requiredField).addClass('is-invalid');
|
||||
missingRequired = true;
|
||||
}
|
||||
});
|
||||
if (missingRequired) {
|
||||
throw new Error('Fields with * are required.');
|
||||
}
|
||||
|
||||
// Validate passwords.
|
||||
if ($('#secretary-password').val() !== $('#secretary-password-confirm').val()) {
|
||||
$('#secretary-password, #secretary-password-confirm').addClass('is-invalid');
|
||||
throw new Error('Passwords mismatch!');
|
||||
}
|
||||
|
||||
if (
|
||||
$('#secretary-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH &&
|
||||
$('#secretary-password').val() !== ''
|
||||
) {
|
||||
$('#secretary-password, #secretary-password-confirm').addClass('is-invalid');
|
||||
throw new Error('Password must be at least ' + BackendUsers.MIN_PASSWORD_LENGTH + ' characters long.');
|
||||
}
|
||||
|
||||
// Validate user email.
|
||||
if (!GeneralFunctions.validateEmail($('#secretary-email').val())) {
|
||||
$('#secretary-email').addClass('is-invalid');
|
||||
throw new Error('Invalid email address!');
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($('#secretary-username').attr('already-exists') === 'true') {
|
||||
$('#secretary-username').addClass('is-invalid');
|
||||
throw new Error('Username already exists.');
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
$('#secretaries .form-message').addClass('alert-danger').text(error.message).show();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the secretary tab form back to its initial state.
|
||||
*/
|
||||
SecretariesHelper.prototype.resetForm = function () {
|
||||
$('#filter-secretaries .selected').removeClass('selected');
|
||||
$('#filter-secretaries button').prop('disabled', false);
|
||||
$('#filter-secretaries .results').css('color', '');
|
||||
|
||||
$('#secretaries .record-details').find('input, select, textarea').val('').prop('disabled', true);
|
||||
$('#secretaries .record-details #secretary-calendar-view').val('default');
|
||||
$('#secretaries .record-details #secretary-timezone').val('UTC');
|
||||
$('#secretaries .add-edit-delete-group').show();
|
||||
$('#secretaries .save-cancel-group').hide();
|
||||
$('#edit-secretary, #delete-secretary').prop('disabled', true);
|
||||
$('#secretaries .form-message').hide();
|
||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||
$('#secretaries .is-invalid').removeClass('is-invalid');
|
||||
};
|
||||
|
||||
/**
|
||||
* Display a secretary record into the secretary form.
|
||||
*
|
||||
* @param {Object} secretary Contains the secretary record data.
|
||||
*/
|
||||
SecretariesHelper.prototype.display = function (secretary) {
|
||||
$('#secretary-id').val(secretary.id);
|
||||
$('#secretary-first-name').val(secretary.first_name);
|
||||
$('#secretary-last-name').val(secretary.last_name);
|
||||
$('#secretary-email').val(secretary.email);
|
||||
$('#secretary-mobile-number').val(secretary.mobile_number);
|
||||
$('#secretary-phone-number').val(secretary.phone_number);
|
||||
$('#secretary-address').val(secretary.address);
|
||||
$('#secretary-city').val(secretary.city);
|
||||
$('#secretary-state').val(secretary.state);
|
||||
$('#secretary-zip-code').val(secretary.zip_code);
|
||||
$('#secretary-notes').val(secretary.notes);
|
||||
$('#secretary-timezone').val(secretary.timezone);
|
||||
|
||||
$('#secretary-username').val(secretary.settings.username);
|
||||
$('#secretary-calendar-view').val(secretary.settings.calendar_view);
|
||||
$('#secretary-notifications').prop('checked', Boolean(Number(secretary.settings.notifications)));
|
||||
|
||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||
|
||||
secretary.providers.forEach(function (secretaryProviderId) {
|
||||
var $checkbox = $('#secretary-providers input[data-id="' + secretaryProviderId + '"]');
|
||||
|
||||
if (!$checkbox.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkbox.prop('checked', true);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters secretary records depending a string key.
|
||||
*
|
||||
* @param {String} key This is used to filter the secretary records of the database.
|
||||
* @param {Numeric} selectId Optional, if provided the given ID will be selected in the filter results
|
||||
* (only selected, not displayed).
|
||||
* @param {Bool} display Optional (false).
|
||||
*/
|
||||
SecretariesHelper.prototype.filter = function (key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_secretaries';
|
||||
|
||||
var data = {
|
||||
csrf_token: GlobalVariables.csrfToken,
|
||||
key: key,
|
||||
limit: this.filterLimit
|
||||
};
|
||||
|
||||
$.post(url, data).done(
|
||||
function (response) {
|
||||
this.filterResults = response;
|
||||
|
||||
$('#filter-secretaries .results').empty();
|
||||
|
||||
response.forEach(
|
||||
function (secretary) {
|
||||
$('#filter-secretaries .results').append(this.getFilterHtml(secretary)).append($('<hr/>'));
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
if (!response.length) {
|
||||
$('#filter-secretaries .results').append(
|
||||
$('<em/>', {
|
||||
'text': App.Lang.no_records_found
|
||||
})
|
||||
);
|
||||
} else if (response.length === this.filterLimit) {
|
||||
$('<button/>', {
|
||||
'type': 'button',
|
||||
'class': 'btn btn-outline-secondary w-100 load-more text-center',
|
||||
'text': App.Lang.load_more,
|
||||
'click': function () {
|
||||
this.filterLimit += 20;
|
||||
this.filter(key, selectId, display);
|
||||
}.bind(this)
|
||||
}).appendTo('#filter-secretaries .results');
|
||||
}
|
||||
|
||||
if (selectId) {
|
||||
this.select(selectId, display);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get an secretary row html code that is going to be displayed on the filter results list.
|
||||
*
|
||||
* @param {Object} secretary Contains the secretary record data.
|
||||
*
|
||||
* @return {String} The html code that represents the record on the filter results list.
|
||||
*/
|
||||
SecretariesHelper.prototype.getFilterHtml = function (secretary) {
|
||||
var name = secretary.first_name + ' ' + secretary.last_name;
|
||||
|
||||
var info = secretary.email;
|
||||
|
||||
info = secretary.mobile_number ? info + ', ' + secretary.mobile_number : info;
|
||||
|
||||
info = secretary.phone_number ? info + ', ' + secretary.phone_number : info;
|
||||
|
||||
return $('<div/>', {
|
||||
'class': 'secretary-row entry',
|
||||
'data-id': secretary.id,
|
||||
'html': [
|
||||
$('<strong/>', {
|
||||
'text': name
|
||||
}),
|
||||
$('<br/>'),
|
||||
$('<span/>', {
|
||||
'text': info
|
||||
}),
|
||||
$('<br/>')
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Select a specific record from the current filter results. If the secretary id does not exist
|
||||
* in the list then no record will be selected.
|
||||
*
|
||||
* @param {Number} id The record id to be selected from the filter results.
|
||||
* @param {Boolean} display Optional (false), if true the method will display the record in the form.
|
||||
*/
|
||||
SecretariesHelper.prototype.select = function (id, display) {
|
||||
display = display || false;
|
||||
|
||||
$('#filter-secretaries .selected').removeClass('selected');
|
||||
|
||||
$('#filter-secretaries .secretary-row[data-id="' + id + '"]').addClass('selected');
|
||||
|
||||
if (display) {
|
||||
var secretary = this.filterResults.find(
|
||||
function (filterResult) {
|
||||
return Number(filterResult.id) === Number(id);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.display(secretary);
|
||||
|
||||
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
||||
}
|
||||
};
|
||||
|
||||
window.SecretariesHelper = SecretariesHelper;
|
||||
})();
|
Loading…
Reference in a new issue