Bug 32016 - Fix 'clear filter' button behavior on datatable saving their state
Summary: Fix 'clear filter' button behavior on datatable saving their state
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial (vote)
Assignee: Thibaud Guillot
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 32303
  Show dependency treegraph
 
Reported: 2022-10-27 12:13 UTC by Thibaud Guillot
Modified: 2023-12-28 20:44 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.09, 21.11.16


Attachments
Bug 32016: Fix clear filter button behavior (3.22 KB, patch)
2022-10-27 12:33 UTC, Thibaud Guillot
Details | Diff | Splinter Review
Bug 32016: Fix clear filter button behavior (3.27 KB, patch)
2022-10-29 00:20 UTC, David Nind
Details | Diff | Splinter Review
Bug 32016: Fix clear filter button behavior (3.33 KB, patch)
2022-11-02 13:42 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 32016: Remove debug console.log (976 bytes, patch)
2022-11-07 08:58 UTC, Thibaud Guillot
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud Guillot 2022-10-27 12:13:16 UTC
Since 20.11, there is only one filter per column or one global filter on 'cgi-bin/koha/acqui/parcel.pl?invoiceid=X' when you want to receive shipments.

With many shopping carts, it can be useful to filter by certain criteria, passed by column or/and by the "global" search input. But when we click receive and get redirected to 'cgi-bin/koha/acqui/orderreceive.pl?ordernumber=X&invoiceid=Y' after saving or canceling action, back to previous page, data table is still filtered but we cannot clear the input from the global search filter.

There is a parameter for datatable which can be passed to false to avoid saving the state of the datatable but this is not a solution because it can be tedious to set again the desired filters.

The problem is related to the fact that the state of the datatable is saved by a cookie, retrieved when loading this same datatable. But when initializing the "clear filter" button, the class disabled is added if the search is empty and the recovery of the cookie is not taken into account.

This is a first correction proposal that I will submit and which corrects the problem on the other datatables which would have the same behavior.
Comment 1 Thibaud Guillot 2022-10-27 12:24:15 UTC
Since 21.11, not 20.11 :)
Comment 2 Thibaud Guillot 2022-10-27 12:33:25 UTC
Created attachment 142713 [details] [review]
Bug 32016: Fix clear filter button behavior

For example, if you filter by global search input a datatable which saves its previous state when you want to return to this datatable, the backup is recovered in a cookie but the "clear filter" button is disabled because for it the input is empty, the verification of the recovery of the cookie not being made.

When loading I therefore added the verification of the cookie and if the search value is not empty then the button can be activated.

Test plan:

1) Be sure to have some orders and baskets which can be received
2) Go to 'cgi-bin/koha/acqui/booksellers.pl' and click on 'Receive
shipments'
3) Enter something in global search
4) Go to receive and cancel or save to be back on datatable
5) See that you cannot remove your previous input by the 'clear filter'
button
6) Apply this patch
7) Repeat steps 3) and 4)
8) See that now you can remove your search

 Current status: NEW
Comment 3 David Nind 2022-10-29 00:20:20 UTC
Created attachment 142797 [details] [review]
Bug 32016: Fix clear filter button behavior

For example, if you filter by global search input a datatable which saves its previous state when you want to return to this datatable, the backup is recovered in a cookie but the "clear filter" button is disabled because for it the input is empty, the verification of the recovery of the cookie not being made.

When loading I therefore added the verification of the cookie and if the search value is not empty then the button can be activated.

Test plan:

1) Be sure to have some orders and baskets which can be received
2) Go to 'cgi-bin/koha/acqui/booksellers.pl' and click on 'Receive
shipments'
3) Enter something in global search
4) Go to receive and cancel or save to be back on datatable
5) See that you cannot remove your previous input by the 'clear filter'
button
6) Apply this patch
7) Repeat steps 3) and 4)
8) See that now you can remove your search

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2022-10-29 00:21:44 UTC
Changed assignee :)
Comment 5 Katrin Fischer 2022-11-02 13:42:05 UTC
Created attachment 142977 [details] [review]
Bug 32016: Fix clear filter button behavior

For example, if you filter by global search input a datatable which saves its previous state when you want to return to this datatable, the backup is recovered in a cookie but the "clear filter" button is disabled because for it the input is empty, the verification of the recovery of the cookie not being made.

When loading I therefore added the verification of the cookie and if the search value is not empty then the button can be activated.

Test plan:

1) Be sure to have some orders and baskets which can be received
2) Go to 'cgi-bin/koha/acqui/booksellers.pl' and click on 'Receive
shipments'
3) Enter something in global search
4) Go to receive and cancel or save to be back on datatable
5) See that you cannot remove your previous input by the 'clear filter'
button
6) Apply this patch
7) Repeat steps 3) and 4)
8) See that now you can remove your search

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Tomás Cohen Arazi 2022-11-04 22:14:51 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 7 Jonathan Druart 2022-11-07 08:14:28 UTC
+            // table_dt.on('search', console.log);

hum?
Comment 8 Thibaud Guillot 2022-11-07 08:58:07 UTC
Created attachment 143347 [details] [review]
Bug 32016: Remove debug console.log
Comment 9 Thibaud Guillot 2022-11-07 08:58:58 UTC
(In reply to Jonathan Druart from comment #7)
> +            // table_dt.on('search', console.log);
> 
> hum?

.. My bad, I forgot it >_< thanks for your feedback
Comment 10 Tomás Cohen Arazi 2022-11-07 10:38:09 UTC
Follow-up pushed to master, thanks!
Comment 11 Lucas Gass 2023-01-18 21:02:22 UTC
Backported to 22.05.x for upcoming 22.05.09
Comment 12 Arthur Suzuki 2023-01-26 09:38:50 UTC
Pushed to 21.11.x for 21.11.16
Comment 13 wainuiwitikapark 2023-03-15 01:27:08 UTC
Not backported to 21.05.x