Bug 32016

Summary: Fix 'clear filter' button behavior on datatable saving their state
Product: Koha Reporter: Thibaud Guillot (thibaud_g) <thibaud.guillot>
Component: AcquisitionsAssignee: Thibaud Guillot (thibaud_g) <thibaud.guillot>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: trivial    
Priority: P5 - low CC: arthur.suzuki, david, jonathan.druart, lucas, tomascohen, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
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
Circulation function:
Bug Depends on:    
Bug Blocks: 32303    
Attachments: Bug 32016: Fix clear filter button behavior
Bug 32016: Fix clear filter button behavior
Bug 32016: Fix clear filter button behavior
Bug 32016: Remove debug console.log

Description Thibaud Guillot (thibaud_g) 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 (thibaud_g) 2022-10-27 12:24:15 UTC
Since 21.11, not 20.11 :)
Comment 2 Thibaud Guillot (thibaud_g) 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 (tcohen) 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 (thibaud_g) 2022-11-07 08:58:07 UTC
Created attachment 143347 [details] [review]
Bug 32016: Remove debug console.log
Comment 9 Thibaud Guillot (thibaud_g) 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 (tcohen) 2022-11-07 10:38:09 UTC
Follow-up pushed to master, thanks!
Comment 11 Lucas Gass (lukeg) 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 Wainui Witika-Park 2023-03-15 01:27:08 UTC
Not backported to 21.05.x