When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data.
Hm, maybe data-search could work?
Created attachment 144951 [details] [review] Bug 32559: Add support for formatted date when filtering on a column When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data. Test plan: Assuming dateformat is set to metric Go to the main patron search, search for all patrons (don't provide a search term) In the "date of birth" column filter, enter "1958", notice that you see Henry Search using an iso formatted date 1958-05-30 Search using a metric formatted date 30/05/1958 Note that: - it's also working for "Expires on" on the same table. We may want to adjust other tables that are using the DT REST API wrapper and the column filters - You need to search for the full formatted date to make it work. "30/05" won't work.
(In reply to Katrin Fischer from comment #1) > Hm, maybe data-search could work? Nope, we need to deal with it "manually", we cannot rely on DT internals. Here we are using the REST API and don't have the data loaded in the DOM already. However I would be happy if someone else come with a better solution.
Created attachment 144954 [details] [review] Bug 32559: Add support for formatted date when filtering on a column When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data. Test plan: Assuming dateformat is set to metric Go to the main patron search, search for all patrons (don't provide a search term) In the "date of birth" column filter, enter "1958", notice that you see Henry Search using an iso formatted date 1958-05-30 Search using a metric formatted date 30/05/1958 Note that: - it's also working for "Expires on" on the same table. We may want to adjust other tables that are using the DT REST API wrapper and the column filters - You need to search for the full formatted date to make it work. "30/05" won't work. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This looks like a reasonable approach.. I did similar in another bug somewhere a while ago, but this implimentation is a little cleaner. Can we get some unit tests for it? There are tests for the dt wrapper right.. I can't entirely remember.
(In reply to Martin Renvoize from comment #5) > This looks like a reasonable approach.. I did similar in another bug > somewhere a while ago, but this implimentation is a little cleaner. > > Can we get some unit tests for it? There are tests for the dt wrapper > right.. I can't entirely remember. Yes, t/db_dependent/selenium/patrons_search.t Good idea, I will provide them.
Created attachment 144977 [details] [review] Bug 32559: Add tests
Excellent, thanks Jonathan. Now we just need the blockers to get unblocked.. I'm chasing Marcel on that as I think he's the most recent touch on them.
The other bug I was talking about was 'Bug 29302 - The dataTables Koha RESTful API wrapper should allow picking match type at the column level'.. where I was trying to do this closer to the datatables JS instantiation rather than in the table header markup.
Ideally we could have use 'type' (https://datatables.net/reference/option/columns.type) with type=date. What I've tried first. But it got removed by DT because it's not useful when server-side processing is used: """Please note that if you are using server-side processing (serverSide) this option has no effect since the ordering and search actions are performed by a server-side script.)"""
Created attachment 145094 [details] [review] Bug 32559: Add support for formatted date when filtering on a column When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data. Test plan: Assuming dateformat is set to metric Go to the main patron search, search for all patrons (don't provide a search term) In the "date of birth" column filter, enter "1958", notice that you see Henry Search using an iso formatted date 1958-05-30 Search using a metric formatted date 30/05/1958 Note that: - it's also working for "Expires on" on the same table. We may want to adjust other tables that are using the DT REST API wrapper and the column filters - You need to search for the full formatted date to make it work. "30/05" won't work. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 145095 [details] [review] Bug 32559: Add tests Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(In reply to Jonathan Druart from comment #10) > Ideally we could have use 'type' > (https://datatables.net/reference/option/columns.type) with type=date. What > I've tried first. > But it got removed by DT because it's not useful when server-side processing > is used: > """Please note that if you are using server-side processing (serverSide) > this option has no effect since the ordering and search actions are > performed by a server-side script.)""" Interesting.. I tried with 'type' instead of 'datatype' and it didn't get dropped for me..
Created attachment 145136 [details] [review] Bug 32559: [ALT] Use column 'type' to pre-process search patterns This patch adds the option to pass 'type' at the 'column' definition level and then binds on that type to add date parsing to queries.
Temporarily in discussion whilst I catch Jonathan... I'm still of the opinion his patchset is a bit more functional than mine.. but I am interested to see why the 'type' term didn't work for him when it worked in my patch? Assuming I'm mis-understanding something somewhere.
*** This bug has been marked as a duplicate of bug 34226 ***
Marking as a duplicate and I'm going to lift the tests out of here to re-use with the other patchset.
Created attachment 153845 [details] [review] Bug 32559: Add support for formatted date when filtering on a column When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data. Test plan: Assuming dateformat is set to metric Go to the main patron search, search for all patrons (don't provide a search term) In the "date of birth" column filter, enter "1958", notice that you see Henry Search using an iso formatted date 1958-05-30 Search using a metric formatted date 30/05/1958 Note that: - it's also working for "Expires on" on the same table. We may want to adjust other tables that are using the DT REST API wrapper and the column filters - You need to search for the full formatted date to make it work. "30/05" won't work. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 153846 [details] [review] Bug 32559: Add tests Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 153847 [details] [review] Bug 32559: [ALT] Use column 'type' to pre-process search patterns This patch adds the option to pass 'type' at the 'column' definition level and then binds on that type to add date parsing to queries.