From 87829331387985689a39ce04f3414100d4d79eb9 Mon Sep 17 00:00:00 2001 From: Rafael te Boekhorst Date: Tue, 24 Jan 2023 09:23:34 +0100 Subject: [PATCH 1/3] small fix for loading holidays correctly --- js/kronolith.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/kronolith.js b/js/kronolith.js index 7863ef77..55a42ee3 100644 --- a/js/kronolith.js +++ b/js/kronolith.js @@ -3853,8 +3853,17 @@ KronolithCore = { data.owner_input = null; } if (data.type == 'holiday') { - this.insertCalendarInList('holiday', data.driver, Kronolith.conf.calendars.holiday[data.driver]); - this.toggleCalendar('holiday', data.driver); + // checking if a holiday is already in the list + let check = this.getCalendarList(data.type).textContent.replace(/[^\w\s]/gi, ''); + if (check === data.driver){ + // if so: only toggle the calendar + this.toggleCalendar('holiday', data.driver); + } + else { + // if not so: add the calendar to the list + this.insertCalendarInList('holiday', data.driver, Kronolith.conf.calendars.holiday[data.driver]); + this.toggleCalendar('holiday', data.driver); + } form.down('.kronolithCalendarSave').enable(); this.closeRedBox(); this.go(this.lastLocation); From 9d35a24c172af2ff4b7665458773c6fded1143c7 Mon Sep 17 00:00:00 2001 From: Rafael te Boekhorst Date: Tue, 24 Jan 2023 09:47:26 +0100 Subject: [PATCH 2/3] adapting regex to deal with multiple calendars --- js/kronolith.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/kronolith.js b/js/kronolith.js index 55a42ee3..1dabc573 100644 --- a/js/kronolith.js +++ b/js/kronolith.js @@ -3854,8 +3854,8 @@ KronolithCore = { } if (data.type == 'holiday') { // checking if a holiday is already in the list - let check = this.getCalendarList(data.type).textContent.replace(/[^\w\s]/gi, ''); - if (check === data.driver){ + let check = this.getCalendarList(data.type).textContent; + if (check.includes(data.driver)){ // if so: only toggle the calendar this.toggleCalendar('holiday', data.driver); } From ed5a8cf1f5e4cb437d9fbef1e6d4cc21da4de279 Mon Sep 17 00:00:00 2001 From: Rafael te Boekhorst Date: Thu, 26 Jan 2023 15:26:30 +0100 Subject: [PATCH 3/3] iterating over list of unselected holidays retoggle them --- js/kronolith.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/js/kronolith.js b/js/kronolith.js index 1dabc573..879a5c25 100644 --- a/js/kronolith.js +++ b/js/kronolith.js @@ -3853,17 +3853,21 @@ KronolithCore = { data.owner_input = null; } if (data.type == 'holiday') { - // checking if a holiday is already in the list - let check = this.getCalendarList(data.type).textContent; - if (check.includes(data.driver)){ - // if so: only toggle the calendar + + // getting the holidays that are listed but unselected + let check = this.getCalendarList(data.type); + let checklist = check.select('span.horde-resource-off').map( + item => item = item.textContent + ); + + // checking if the new calendar is in the unselected list + if (checklist.indexOf(data.driver) > -1){ this.toggleCalendar('holiday', data.driver); - } - else { - // if not so: add the calendar to the list + }else{ this.insertCalendarInList('holiday', data.driver, Kronolith.conf.calendars.holiday[data.driver]); this.toggleCalendar('holiday', data.driver); } + form.down('.kronolithCalendarSave').enable(); this.closeRedBox(); this.go(this.lastLocation);