From 89c91fbf8bd4d38ef7290689df8b41286ca89b1d Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 17 Jan 2022 15:31:04 +0100 Subject: [PATCH] Code refactoring and improvements for the working plan utilities page. --- assets/js/utils/working_plan.js | 1420 +++++++++++++++---------------- 1 file changed, 707 insertions(+), 713 deletions(-) diff --git a/assets/js/utils/working_plan.js b/assets/js/utils/working_plan.js index 198f82ed..6651a707 100755 --- a/assets/js/utils/working_plan.js +++ b/assets/js/utils/working_plan.js @@ -23,14 +23,14 @@ App.Utils.WorkingPlan = (function () { * * @class WorkingPlan */ - const WorkingPlan = function () { + 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} */ - this.enableCancel = false; + enableCancel = false; /** * This flag determines whether the jeditables are allowed to submit. It is @@ -38,758 +38,752 @@ App.Utils.WorkingPlan = (function () { * * @type {Boolean} */ - this.enableSubmit = false; - }; + 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) { - const weekDayId = App.Utils.Date.getWeekdayId(App.Vars.first_weekday); - const workingPlanSorted = App.Utils.Date.sortWeekDictionary(workingPlan, weekDayId); + /** + * 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(App.Vars.first_weekday); + const workingPlanSorted = App.Utils.Date.sortWeekDictionary(workingPlan, weekDayId); - $('.working-plan tbody').empty(); - $('.breaks tbody').empty(); + $('.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 = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'; + // Build working plan day list starting with the first weekday as set in the General settings + const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'; - $.each( - workingPlanSorted, - function (index, workingDay) { - const day = this.convertValueToDay(index); + $.each( + workingPlanSorted, + function (index, workingDay) { + const day = this.convertValueToDay(index); - const dayDisplayName = App.Utils.String.upperCaseFirstLetter(day); + const dayDisplayName = App.Utils.String.upperCaseFirstLetter(day); - $('', { - 'html': [ - $('', { - 'html': [ - $('
', { - 'class': 'checkbox form-check', - 'html': [ - $('', { - 'class': 'form-check-input', - 'type': 'checkbox', - 'id': index - }), - $('