Bug 34352

Summary: It would be great to have a generic flatpickr based input for datatables column filters
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: TemplatesAssignee: Martin Renvoize <martin.renvoize>
Status: Patch doesn't apply --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, katrin.fischer, lucas, oleonard, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29422
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34358
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30113
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 34226    
Bug Blocks:    
Attachments: Bug 34352: Enable flatpickr on patron search
Bug 34352: Add allowyear to flatpickr options

Description Martin Renvoize 2023-07-24 11:36:01 UTC
In bug 34226 I attempted to add flatpickr inputs for the column filtering in ajax driven datatables.

It worked well in the case I experimented on, but wasn't quite enough for the more generic handling I was aiming for.

We need to support flatpickr without having to import calender.inc in a rather specific load order and we could do with still being able to search on year only rather than always having to specify a full date.
Comment 1 Martin Renvoize 2023-07-25 13:31:25 UTC
Created attachment 153873 [details] [review]
Bug 34352: Enable flatpickr on patron search
Comment 2 Martin Renvoize 2023-07-25 13:31:27 UTC
Created attachment 153874 [details] [review]
Bug 34352: Add allowyear to flatpickr options

An attempt at allowing four digit years to be entered into the flatpickr
bound date filter input.

However, we're triggering at the wrong stage and I'm not sure where else
to look right now :(.
Comment 3 Martin Renvoize 2023-07-25 13:35:26 UTC
The first patch here enables the flatpickr for `type: "date"` columns in our datatables wrapper (this can be tested on the patron search results page, where we already set date types for dateofbirth and expirationdate fields in bug 34226).

However, the caveat is this allows only fully formed dates to be input which prevents end users from filtering on year only (or day, or month for that matter). Jonathan raised this as a possible issue and so I tried to update flatpickr to allow 4 digit dates to be entered into the input box.. I failed however, but my attempt is attached in case anyone wants to give it a try.
Comment 4 Jonathan Druart 2023-07-27 08:49:56 UTC
I didn't manage to bypass the flatpickr validation step, which actually happens before onClose.

Btw it seems that this validate_date call is not needed.
Comment 5 Lucas Gass 2024-04-22 22:50:50 UTC
Doesn't apply. I'd be happy to revisit this myself if I can ever get Bug 33703 in. :P
Comment 6 Martin Renvoize 2024-05-02 11:03:31 UTC
Woop, woop.. bug 33703 got in now :)