/* ---------------------------------------------------------------------------- * Easy!Appointments - Online Appointment 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.5.0 * ---------------------------------------------------------------------------- */ /** * Working plan utility. * * This module implements the functionality of working plans. */ App.Utils.WorkingPlan = (function () { /** * Class WorkingPlan * * Contains the working plan functionality. The working plan DOM elements must be same * in every page this class is used. * * @class WorkingPlan */ class WorkingPlan { /** * This flag is used when trying to cancel row editing. It is * true only whenever the user presses the cancel button. * * @type {Boolean} */ enableCancel = false; /** * This flag determines whether the jeditables are allowed to submit. It is * true only whenever the user presses the save button. * * @type {Boolean} */ enableSubmit = false; /** * Setup the dom elements of a given working plan. * * @param {Object} workingPlan Contains the working hours and breaks for each day of the week. */ setup(workingPlan) { const weekDayId = App.Utils.Date.getWeekdayId(vars('first_weekday')); const workingPlanSorted = App.Utils.Date.sortWeekDictionary(workingPlan, weekDayId); $('.working-plan tbody').empty(); $('.breaks tbody').empty(); // Build working plan day list starting with the first weekday as set in the General settings const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm'; $.each( workingPlanSorted, function (index, workingDay) { const day = this.convertValueToDay(index); const dayDisplayName = App.Utils.String.upperCaseFirstLetter(day); $('', { 'html': [ $('', { 'html': [ $('
', { 'class': 'checkbox form-check', 'html': [ $('', { 'class': 'form-check-input', 'type': 'checkbox', 'id': index, }), $('