iflrandevu/assets/js/pages/backend_services.js

92 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-07-20 22:41:24 +03:00
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
2015-07-20 22:41:24 +03:00
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
2021-12-18 19:43:45 +03:00
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
2015-07-20 22:41:24 +03:00
* @since v1.0.0
* ---------------------------------------------------------------------------- */
window.BackendServices = window.BackendServices || {};
/**
* Backend Services
*
* This namespace handles the js functionality of the backend services page.
*
* @module BackendServices
*/
2018-01-23 12:08:37 +03:00
(function (exports) {
'use strict';
/**
* Contains the basic record methods for the page.
*
* @type {ServicesHelper}
*/
var helper;
2018-01-23 12:08:37 +03:00
var servicesHelper = new ServicesHelper();
/**
* Default initialize method of the page.
*
* @param {Boolean} [defaultEventHandlers] Optional (true), determines whether to bind the default event handlers.
*/
exports.initialize = function (defaultEventHandlers) {
defaultEventHandlers = defaultEventHandlers || true;
// Instantiate helper object (service helper by default).
helper = servicesHelper;
helper.resetForm();
helper.filter('');
helper.bindEventHandlers();
if (defaultEventHandlers) {
bindEventHandlers();
}
BackendServices.updateAvailableCategories();
Backend.placeFooterToBottom();
};
/**
* Binds the default event handlers of the backend services page.
*
* Do not use this method if you include the "BackendServices" namespace on another page.
*/
function bindEventHandlers() {
//
}
/**
* Update the service category list box.
*
* Use this method every time a change is made to the service categories db table.
*/
2018-01-23 12:08:37 +03:00
exports.updateAvailableCategories = function () {
var url = GlobalVariables.baseUrl + '/index.php/categories/search';
var data = {
csrf_token: GlobalVariables.csrfToken,
2016-07-15 21:52:21 +03:00
key: ''
};
$.post(url, data).done(function (response) {
GlobalVariables.categories = response;
var $select = $('#service-category');
$select.empty();
response.forEach(function (category) {
$select.append(new Option(category.name, category.id));
2020-12-02 20:57:49 +03:00
});
$select.append(new Option('- ' + App.Lang.no_category + ' -', null)).val('null');
});
};
})(window.BackendServices);