/* ---------------------------------------------------------------------------- * Easy!Appointments - Open Source Web Scheduler * * @package EasyAppointments * @author A.Tselegidis * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 * @link http://easyappointments.org * @since v1.0.0 * ---------------------------------------------------------------------------- */ (function () { 'use strict'; /** * Class WorkingPlan * * Contains the working plan functionality. The working plan DOM elements must be same * in every page this class is used. * * @class WorkingPlan */ var WorkingPlan = function () { /** * This flag is used when trying to cancel row editing. It is * true only whenever the user presses the cancel button. * * @type {Boolean} */ this.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} */ this.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. */ WorkingPlan.prototype.setup = function (workingPlan) { var weekDayId = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday); var workingPlanSorted = GeneralFunctions.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 var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'; $.each(workingPlanSorted, function (index, workingDay) { var day = this.convertValueToDay(index); var dayDisplayName = GeneralFunctions.upperCaseFirstLetter(day) $('', { 'html': [ $('', { 'html': [ $('
', { 'class': 'checkbox form-check', 'html': [ $('', { 'class': 'form-check-input', 'type': 'checkbox', 'id': index }), $('