From 12cbbef8712f0a246b8a026010d7781bb2bfa8c2 Mon Sep 17 00:00:00 2001 From: Slava Shishkin Date: Thu, 9 Oct 2025 14:36:27 +0300 Subject: [PATCH] Bug 40982: Basket: Fix cached visibility for Modify/Cancel order columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing notes (using KTD) Note: before starting, set CancelOrdersInClosedBaskets = Allow. /cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CancelOrdersInClosedBaskets Add an order to a basket: 1. Acquisitions → Search vendors → Search 2. Click the vendor name 3. In the Baskets column, click the link 4. Select a basket (or create a new one) 5. Add at least one order 6. In the open basket, verify that the Modify and Cancel order columns are absent. 7. Close the basket (you’ll return to the vendor’s basket list). Open the same closed basket and verify that the Cancel order column is absent, even though it should be present (because CancelOrdersInClosedBaskets = Allow). 8. Apply the patch and repeat steps 1–7. 9. At step 6 (open basket), the Modify and Cancel order columns are displayed. 10. At step 7 (closed basket), the Cancel order column is visible according to the CancelOrdersInClosedBaskets setting. --- .../prog/en/modules/acqui/basket.tt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index d9b27c670c3..a51f97e5536 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -1260,6 +1260,32 @@ table_settings.columns.find(c => c.columnname == 'cancel').is_hidden = 0; [% END %] + // Sync cached visibility of Modify (21) and Cancel (22) with TT logic + (function () { + var modifyVisible = [% IF active && !closedate %]true[% ELSE %]false[% END %]; + var cancelVisible = [% IF !closedate || Koha.Preference('CancelOrdersInClosedBaskets') %]true[% ELSE %]false[% END %]; + + for (var i = 0; i < localStorage.length; i++) { + var key = localStorage.key(i); + if (!key || key.indexOf('DataTables_acqui_basket_orders') !== 0) continue; + + try { + var stRaw = localStorage.getItem(key); + if (!stRaw) continue; + var st = JSON.parse(stRaw); + if (!st || !Array.isArray(st.columns) || st.columns.length < 23) continue; + + // enforce visibility on last two columns (21, 22) + if (st.columns[21]) st.columns[21].visible = modifyVisible; + if (st.columns[22]) st.columns[22].visible = cancelVisible; + + localStorage.setItem(key, JSON.stringify(st)); + } catch (_e) { + } + } + })(); + + $("#orders").kohaTable({ bKohaColumnsUseNames: true, pagingType: "full", -- 2.51.0