Bug 42292: (follow-up) Replace removed dateformat_pref var in OPAC calendar.inc
The OPAC port moved the dateformat pref into Koha.addPrefs and dropped the local `var dateformat_pref = ...;` declaration, but four usages of `dateformat_pref` remain in the same file (the debug alert, two `switch` statements, and the get_dateformat_str call in validate_date). At runtime the switches throw ReferenceError, so flatpickr ends up with the default 'Y-m-d' format and date validation via validate_date crashes before showing the invalid-date alert. Replace all remaining occurrences with Koha.prefs.dateformat, which is populated by the new addPrefs block at the top of the include. To test: - Set dateformat syspref to each of us / metric / dmydot / iso. - Open any OPAC page using a flatpickr input (e.g. hold date, patron dob on the registration form). - Confirm the widget renders dates in the expected format and entering an invalid string triggers the validate_date alert. - No ReferenceError in the browser console on page load. Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: Jan Kissig <bibliothek@th-wildau.de> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
e53b7346c9
commit
ed7fef7dd7
|
|
@ -21,7 +21,7 @@
|
|||
};
|
||||
var sentmsg = 0;
|
||||
if (debug > 1) {
|
||||
alert("dateformat: " + dateformat_pref + "\ndebug is on (level " + debug + ")");
|
||||
alert("dateformat: " + Koha.prefs.dateformat + "\ndebug is on (level " + debug + ")");
|
||||
}
|
||||
var calendarFirstDayOfWeek = Koha.prefs.CalendarFirstDayOfWeek;
|
||||
var flatpickr_timeformat_string = Koha.prefs.TimeFormat == "12hr" ? "G:i K" : "H:i";
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
var flatpickr_dateformat_string = "";
|
||||
var delimiter = "";
|
||||
var altinput_dateformat = "";
|
||||
switch (dateformat_pref) {
|
||||
switch (Koha.prefs.dateformat) {
|
||||
case "us":
|
||||
flatpickr_dateformat_string = "m/d/Y";
|
||||
altinput_dateformat = "mm/dd/yyyy";
|
||||
|
|
|
|||
Loading…
Reference in New Issue