Bug 40753

Summary: DT's SaveState not working on the orders table
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: david, gmcharlt, mteal
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39930
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes the basket order table so that when you close (or reopen) a basket, the columns shown remain the same as the table configuration. Before this fix, if you closed a basket and then reopened it, the table settings columns hidden by default were ignored and all the possible columns were shown.
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on: 33484    
Bug Blocks:    
Attachments: Bug 40753: Fix DT's SaveState on the orders table
Bug 40753: Fix DT's SaveState on the orders table
Bug 40753: Fix DT's SaveState on the orders table

Description Jonathan Druart 2025-09-04 10:49:20 UTC

    
Comment 1 Jonathan Druart 2025-09-04 10:58:44 UTC
Created attachment 186140 [details] [review]
Bug 40753: Fix DT's SaveState on the orders table

We build the the orders table depending on some conditions (sysprefs or if the
basket is closed/opened).
DataTables cannot correctly restore the state because the number of columns
stored in localStorage is different than the one we have one the table.

Test plan:
Open and close a basket
Confirm that the table is correctly displayed (no extra columns)
Comment 2 Jonathan Druart 2025-09-04 11:00:51 UTC
Initially reported on bug 39930 comment 1
Comment 3 David Nind 2025-09-04 23:02:50 UTC
Created attachment 186184 [details] [review]
Bug 40753: Fix DT's SaveState on the orders table

We build the the orders table depending on some conditions (sysprefs or if the
basket is closed/opened).
DataTables cannot correctly restore the state because the number of columns
stored in localStorage is different than the one we have one the table.

Test plan:
Open and close a basket
Confirm that the table is correctly displayed (no extra columns)

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2025-09-04 23:15:10 UTC
Testing notes (using KTD):

1. Add an item to a basket:
   1.1 Go to Acquisitions > Search vendors > Search
   1.2 Click My Vendor in the results (name column)
   1.3 Under the 'Baskets' column, click the link
   1.4 Select 'My Basket'
   1.5 Add an item to the basket
2. Note that these columns are displayed (these should match the columns displayed by default for the table configuration):
   . No.
   . Order
   . RRP tax exc.
   . Actual cost tax exc.
   . Budgeted cost tax exc.
   . Budgeted cost tax inc.
   . Replacement price
   . Qty.
   . Total tax exc. (USD)
   . GST %
   . GST
   . Fund
   . Estimated delivery date
   . Invoice
   . Place hold
3. Close the basket (Result = you go back to the list of baskets for the vendor).
4. Click the basket you just closed.
5. The table now shows all columns, including those hidden by default in the table configuration.
6. Apply the patch.
7. Reset everything (reset_all).
8. Repeat steps 1-4.
9. The columns now shown should be the same (and should reflect the default columns configured, and not show the hidden by default columns).

Note: When saving changes to the table configuration, unless you untick 'Save configuration state on page change' and tick 'Save search state on page change', the changes are only shown after you log out and log back in again.

Before the patch, the columns hidden by default in the table configuration were incorrectly shown when the basket was closed.
Comment 5 Nick Clemens (kidclamp) 2025-09-05 16:17:38 UTC
Created attachment 186239 [details] [review]
Bug 40753: Fix DT's SaveState on the orders table

We build the the orders table depending on some conditions (sysprefs or if the
basket is closed/opened).
DataTables cannot correctly restore the state because the number of columns
stored in localStorage is different than the one we have one the table.

Test plan:
Open and close a basket
Confirm that the table is correctly displayed (no extra columns)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Lucas Gass (lukeg) 2025-09-05 21:20:00 UTC
Nice work everyone!

Pushed to main for 25.11