Bug 38358: Do not allow selecting past dates when editing existing holidays "To date" input

When you are editing holidays "To date" inputs calendar doesn't follow the
"From date" date. Instead calendar offers you today's date/month and
you must click calendar forward to the right date/month. This patch
adds check to determine if user is adding new holiday or editing
existing one and adjusts the code to disable past dates counting from
selected "From date" in both cases.

To test:
1. Navigate to calendar tool (Tools->Calendar).
2. Add new holiday and select "To date" for it.
=> Note that you are unable to select dates past from "From date".
3. Edit existing holiday and select "To date" for it.
=> Note that "To date" input calendar allows selecting dates past
"From date".
=> If you chosed holiday from incoming month, note that "To date"
calendar still opens up to this month.
4. Apply this patch, restart services if needed.
5. Edit existing holiday again.
=> Note that now "To date" inputs calendar works the same way as
it is working when your adding a new holiday.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Emmi Takkinen 2026-07-07 14:23:27 +03:00 committed by Pedro Amorim
parent 430281a59a
commit aaa3954c8f
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 22 additions and 9 deletions

View File

@ -668,19 +668,32 @@
},
onChange: function (selectedDates, dateStr, instance) {
var fromdate = selectedDates[0];
var enddate = dateofrange.selectedDates[0];
dateChanged(fromdate);
dateofrange.set("defaultDate", fromdate);
dateofrange.set("minDate", fromdate);
if (enddate != undefined) {
if (enddate < fromdate) {
dateofrange.set("defaultDate", fromdate);
dateofrange.setDate(fromdate);
/* we need to wait animations to complete in order
to determine if calendar opened is for adding a new
holiday or for editing an existing one */
setTimeout(function () {
var calendar;
if ($("#newHoliday").is(":visible")) {
calendar = dateofrange;
} else if ($("#showHoliday").is(":visible")) {
calendar = datecancelrange;
}
}
var enddate = calendar.selectedDates[0];
calendar.set("defaultDate", fromdate);
calendar.set("minDate", fromdate);
if (enddate != undefined) {
if (enddate < fromdate) {
calendar.set("defaultDate", fromdate);
calendar.setDate(fromdate);
}
}
}, 250);
},
defaultDate: new Date(keydate),
});