Bug 27402 - Add column filtering to the Datatables REST API wrapper
Summary: Add column filtering to the Datatables REST API wrapper
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 24561 27353
Blocks: 27467 20212 27465
  Show dependency treegraph
 
Reported: 2021-01-12 09:03 UTC by Jonathan Druart
Modified: 2022-06-06 20:25 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This development adds native DataTables column filtering to the REST API wrapper. This allows easily adding column filters to DataTables using the REST API. A sample implementation is added to the cities admin page, for reference.
Version(s) released in:
21.05.00


Attachments
Bug 27402: Add DT column filtering to the cities admin page (3.58 KB, patch)
2021-01-12 09:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27402: Move to datatables.js (5.07 KB, patch)
2021-01-12 09:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
add fixedHeader (9.49 KB, patch)
2021-01-12 09:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27402: Column filters must AND, not OR (3.82 KB, patch)
2021-01-12 09:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27402: Add DT column filtering to the cities admin page (3.64 KB, patch)
2021-01-26 13:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27402: Move to datatables.js (5.13 KB, patch)
2021-01-26 13:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27402: Column filters must AND, not OR (3.88 KB, patch)
2021-01-26 13:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27402: Add DT column filtering to the cities admin page (3.70 KB, patch)
2021-01-28 14:34 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27402: Move to datatables.js (5.19 KB, patch)
2021-01-28 14:34 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27402: Column filters must AND, not OR (3.94 KB, patch)
2021-01-28 14:34 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27402: Reverse search filter texts (1.15 KB, patch)
2021-01-28 15:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27402: Reverse search filter texts (1.15 KB, patch)
2021-01-28 15:43 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2021-01-12 09:03:50 UTC
Bug 24561 added a wrapper to use easily all the DataTables functionalities when a REST API route was used within Koha.

The filtering method used is working for the global search filter, but not if we have a filter on top of each column.
Comment 1 Jonathan Druart 2021-01-12 09:14:36 UTC
Created attachment 115051 [details] [review]
Bug 27402: Add DT column filtering to the cities admin page

Bug 24561 added a wrapper to use easily all the DataTables functionalities when a REST API route was used within Koha.

The filtering method used is working for the global search filter, but not if we have a filter on top of each column.

This patchset is going to, first, add the filters on top of each column
of the cities table, then the code will be moved to the DT REST API wrapper to make it reusable easily.

Test plan:

Generate some cities:
  use Koha::Cities;
  for ( 1 .. 42 ) {
      Koha::City->new({city_name => "name_$_", city_state => "state_$_", city_country => "country_$_", city_zipcode => "zipcode_$_" })->store;
  }
Hit /admin/cities.pl
Use the filters

The general filter must do a OR query on each of the cities' attributes,
when column filters must use AND
Comment 2 Jonathan Druart 2021-01-12 09:14:39 UTC
Created attachment 115052 [details] [review]
Bug 27402: Move to datatables.js

To make it reusable we need to move the code to datatables.js

So far only the cities table is using the column filters so there is no other
view to test.

Note that the existing implementation didn't work at all, and were base
on what is done on the detail.pl page (using table_filters.js)
Comment 3 Jonathan Druart 2021-01-12 09:21:04 UTC
Created attachment 115053 [details] [review]
add fixedHeader
Comment 4 Jonathan Druart 2021-01-12 09:21:39 UTC
Created attachment 115054 [details] [review]
Bug 27402: Column filters must AND, not OR

Test plan:
Use the column filters and the global filter
Confirm that the rows are filtered as you expect

QA Note: There is more code on top of this, see bug 20212.
Comment 5 Tomás Cohen Arazi 2021-01-26 13:12:56 UTC
I can't say I'm impressed by your skills, Jonathan. But this is super cool.
Comment 6 Tomás Cohen Arazi 2021-01-26 13:13:34 UTC
Created attachment 115813 [details] [review]
Bug 27402: Add DT column filtering to the cities admin page

Bug 24561 added a wrapper to use easily all the DataTables functionalities when a REST API route was used within Koha.

The filtering method used is working for the global search filter, but not if we have a filter on top of each column.

This patchset is going to, first, add the filters on top of each column
of the cities table, then the code will be moved to the DT REST API wrapper to make it reusable easily.

Test plan:

Generate some cities:
  use Koha::Cities;
  for ( 1 .. 42 ) {
      Koha::City->new({city_name => "name_$_", city_state => "state_$_", city_country => "country_$_", city_zipcode => "zipcode_$_" })->store;
  }
Hit /admin/cities.pl
Use the filters

The general filter must do a OR query on each of the cities' attributes,
when column filters must use AND

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 7 Tomás Cohen Arazi 2021-01-26 13:13:38 UTC
Created attachment 115814 [details] [review]
Bug 27402: Move to datatables.js

To make it reusable we need to move the code to datatables.js

So far only the cities table is using the column filters so there is no other
view to test.

Note that the existing implementation didn't work at all, and were base
on what is done on the detail.pl page (using table_filters.js)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 8 Tomás Cohen Arazi 2021-01-26 13:13:42 UTC
Created attachment 115815 [details] [review]
Bug 27402: Column filters must AND, not OR

Test plan:
Use the column filters and the global filter
Confirm that the rows are filtered as you expect

QA Note: There is more code on top of this, see bug 20212.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi 2021-01-26 13:14:19 UTC
(In reply to Tomás Cohen Arazi from comment #5)
> I can't say I'm impressed by your skills, Jonathan. But this is super cool.

This tried to mean I'm already used to seeing you do smart things :-D
Comment 10 Martin Renvoize 2021-01-28 14:34:03 UTC
Created attachment 115935 [details] [review]
Bug 27402: Add DT column filtering to the cities admin page

Bug 24561 added a wrapper to use easily all the DataTables functionalities when a REST API route was used within Koha.

The filtering method used is working for the global search filter, but not if we have a filter on top of each column.

This patchset is going to, first, add the filters on top of each column
of the cities table, then the code will be moved to the DT REST API wrapper to make it reusable easily.

Test plan:

Generate some cities:
  use Koha::Cities;
  for ( 1 .. 42 ) {
      Koha::City->new({city_name => "name_$_", city_state => "state_$_", city_country => "country_$_", city_zipcode => "zipcode_$_" })->store;
  }
Hit /admin/cities.pl
Use the filters

The general filter must do a OR query on each of the cities' attributes,
when column filters must use AND

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2021-01-28 14:34:06 UTC
Created attachment 115936 [details] [review]
Bug 27402: Move to datatables.js

To make it reusable we need to move the code to datatables.js

So far only the cities table is using the column filters so there is no other
view to test.

Note that the existing implementation didn't work at all, and were base
on what is done on the detail.pl page (using table_filters.js)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2021-01-28 14:34:09 UTC
Created attachment 115937 [details] [review]
Bug 27402: Column filters must AND, not OR

Test plan:
Use the column filters and the global filter
Confirm that the rows are filtered as you expect

QA Note: There is more code on top of this, see bug 20212.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize 2021-01-28 14:34:33 UTC
This is really nice, and clearly well thought through.

Passing QA
Comment 14 Jonathan Druart 2021-01-28 15:18:11 UTC
Created attachment 115942 [details] [review]
Bug 27402: Reverse search filter texts
Comment 15 Jonathan Druart 2021-01-28 15:43:16 UTC
Created attachment 115966 [details] [review]
Bug 27402: Reverse search filter texts
Comment 16 Jonathan Druart 2021-01-28 16:34:53 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 17 Fridolin Somers 2021-02-01 13:45:35 UTC
Enhancement not pushed to 20.11.x