Bug 38081

Summary: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc
Product: Koha Reporter: CJ Lynce <cj.lynce>
Component: Architecture, internals, and plumbingAssignee: CJ Lynce <cj.lynce>
Status: RESOLVED FIXED QA Contact: Lucas Gass (lukeg) <lucas>
Severity: minor    
Priority: P5 - low CC: lucas
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:
Bug Depends on: 36594    
Bug Blocks:    
Attachments: Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc
Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc
Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc

Description CJ Lynce 2024-10-03 17:59:08 UTC
Whenediting a library's information via Administration->Libraries->Edit, a 'TypeError' is being thrown to the console.

I've traced it back to the maskito mask that is applied via Flatpickr. The root cause seems to be that maskito does not properly support 12-hour time formats for time-only masks via the maskitoTimeOptionsGenerator function.
Comment 1 CJ Lynce 2024-10-03 18:25:11 UTC
Created attachment 172366 [details] [review]
Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc

This patch corrects an issue where flatpickr time-only input boxes
    boxes were not having their inputs masked (limited) properly
    due to maskitoTimeOptionsGenerator not properly supporting
    12-hour time inputs for time-only input boxes.

To test:
1. Login to the staff intranet.
2. Open Administration->Libraries-> Edit any library.
3. Open your browser's development console (typically via F12)
    Verify a 'TypeError' message has been thrown for this page.
4. Type in any text into any of the opening hours
    This should be limiting only to properly formatted HH:MM.
5. Apply patch
6. Repeat steps 2-4
    Verify no errors show on your browser's development console.
    Verify opening hours entry are limited to proper HH:MM format.
7. Open Administration->System Preferences and change TimeFormat
    to 12-hours, Save.
8. Repeat steps 2-4
    Verify opening hours text entry are limited to properly
    formatted HH:MM AM/PM (or am/pm)
Comment 2 CJ Lynce 2024-10-03 18:27:48 UTC
It appears that support for 12-hour formats is in the works for maskitoTimeOptions Generator: https://github.com/taiga-family/maskito/issues/1169

This should be revisited once that support has been added. (A manual mask is being used in the mean-time)
Comment 3 Jonathan Druart 2024-10-07 09:43:44 UTC
Created attachment 172449 [details] [review]
Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc

This patch corrects an issue where flatpickr time-only input boxes
    boxes were not having their inputs masked (limited) properly
    due to maskitoTimeOptionsGenerator not properly supporting
    12-hour time inputs for time-only input boxes.

To test:
1. Login to the staff intranet.
2. Open Administration->Libraries-> Edit any library.
3. Open your browser's development console (typically via F12)
    Verify a 'TypeError' message has been thrown for this page.
4. Type in any text into any of the opening hours
    This should be limiting only to properly formatted HH:MM.
5. Apply patch
6. Repeat steps 2-4
    Verify no errors show on your browser's development console.
    Verify opening hours entry are limited to proper HH:MM format.
7. Open Administration->System Preferences and change TimeFormat
    to 12-hours, Save.
8. Repeat steps 2-4
    Verify opening hours text entry are limited to properly
    formatted HH:MM AM/PM (or am/pm)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Lucas Gass (lukeg) 2024-10-07 17:16:56 UTC
Created attachment 172495 [details] [review]
Bug 38081: maskitoTimeOptionsGenerator does not properly support 12-hour times in calendar.inc

This patch corrects an issue where flatpickr time-only input boxes
    boxes were not having their inputs masked (limited) properly
    due to maskitoTimeOptionsGenerator not properly supporting
    12-hour time inputs for time-only input boxes.

To test:
1. Login to the staff intranet.
2. Open Administration->Libraries-> Edit any library.
3. Open your browser's development console (typically via F12)
    Verify a 'TypeError' message has been thrown for this page.
4. Type in any text into any of the opening hours
    This should be limiting only to properly formatted HH:MM.
5. Apply patch
6. Repeat steps 2-4
    Verify no errors show on your browser's development console.
    Verify opening hours entry are limited to proper HH:MM format.
7. Open Administration->System Preferences and change TimeFormat
    to 12-hours, Save.
8. Repeat steps 2-4
    Verify opening hours text entry are limited to properly
    formatted HH:MM AM/PM (or am/pm)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 5 Lucas Gass (lukeg) 2024-10-07 17:17:14 UTC
Thanks CJ, changes look good.
Comment 6 Katrin Fischer 2024-10-11 10:27:57 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 7 Lucas Gass (lukeg) 2024-11-18 23:19:15 UTC
Doesn't cleanly apply to 24.05.x, rebase if needed.