Bug 29302

Summary: The dataTables Koha RESTful API wrapper should allow picking match type at the column level
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: Architecture, internals, and plumbingAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: RESOLVED LATER QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 29408    
Bug Blocks: 29422    
Attachments: Bug 29302: Allow passing of 'criteria' at the column level
Bug 29302: Allow passing of 'criteria' at the column level
Bug 29302: Allow passing of 'criteria' at the column level

Description Martin Renvoize (ashimema) 2021-10-21 16:59:12 UTC
Whilst trying to understand how the `criteria` functionality of the datatables wrapper works, I discovered that is only works at the options level (i.e all searchable fields have the same match criteria applied).

We should be able to set the match criteria at the column level, for example you may want 'exact' match for fields that contain AV codes, or 'starts_with' one field and 'contains' for another.
Comment 1 Martin Renvoize (ashimema) 2021-10-21 17:02:26 UTC
Created attachment 126673 [details] [review]
Bug 29302: Allow passing of 'criteria' at the column level

This patch adds the option to pass 'criteria' at the 'column' definition
level which means you can set 'contains', 'starts_with', 'ends_with' and
'exact' match types for each different column.
Comment 2 Martin Renvoize (ashimema) 2021-10-21 17:03:31 UTC
I ended up needing something a bit more than this in my own bug (I want 'before' and 'after' date support).. but I wanted to post the basics here as a starting point.
Comment 3 Martin Renvoize (ashimema) 2021-11-05 08:15:37 UTC
I'm tempted to rename the key too.. 'criteria' isn't hugely clear and it took me reading the code to figure out.

Perhaps 'comparator or 'comparison_operator' would more clearly reflect its function?
Comment 4 Martin Renvoize (ashimema) 2021-11-05 11:18:30 UTC
Created attachment 127358 [details] [review]
Bug 29302: Allow passing of 'criteria' at the column level

This patch adds the option to pass 'criteria' at the 'column' definition
level which means you can set 'contains', 'starts_with', 'ends_with' and
'exact' match types for each different column.
Comment 5 Martin Renvoize (ashimema) 2022-02-17 15:51:58 UTC
This is a little naive in its approach.

Whilst I still think it would be useful to be able to specify the match type per column, I think we need to distinguish between 'search' and 'filter' operations.

When executing a 'search', it makes sense to perform 'contains', 'starts_with' type searches.. but for a 'filter' (i.e. at the individual column level) you might have a select like and want to do an 'exact' type match.  As such, I think we need to be able to specify more granularly still.
Comment 6 Martin Renvoize (ashimema) 2022-07-14 09:14:53 UTC
Created attachment 137695 [details] [review]
Bug 29302: Allow passing of 'criteria' at the column level

This patch adds the option to pass 'criteria' at the 'column' definition
level which means you can set 'contains', 'starts_with', 'ends_with' and
'exact' match types for each different column.