From 8e0d0268af9786b8ced01def5f70a1b6c344ed2a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 13 Feb 2024 11:48:35 +0000 Subject: [PATCH] Bug 36064: (follow-up) Activate correct tab This patch makes a change to the JavaScript on waitingreserves.pl so that the correct tab is activated if you follow the "Holds with cancellation requests" link on the home page. The page has code to activate the last viewed tab, but I've modified it so that if there is a location hash ('waitingreserves.pl#tab') the tab specified in the hash is selected instead of the last used tab. If there is no location hash the last active tab will be activated. I've also corrected the location hash in the link on the home page. To test, apply the patch and follow the "Holds with cancellation requests" link. The "Holds with cancellation requests" tab should be active. Click a different tab, e.g. "Holds waiting." Go the the circulation home page, then click the link for "Holds awaiting pickup." The tab you selected should be active. Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/circ/waitingreserves.tt | 13 ++++++++++--- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt index 3a0254a955d..80d7bd91d62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -302,9 +302,16 @@ localStorage.selectedWaitingHolds = JSON.stringify(this_dt.$(".select_hold:checked", {"page": "all"}).toArray().map(el => $(el).data('id'))); }); - var activeTab = localStorage.getItem("waitingreserves_activetab"); - if( activeTab ){ - $("div#resultlist li:eq(" + activeTab + ") a").tab("show"); + var hash = document.location.hash; + if( hash !== "" ){ + /* The existence of location.hash means someone clicked a link which targets a specific tab */ + $( hash ).tab("show"); + } else { + /* If no specific tab was linked to, use the last active tab */ + var activeTab = localStorage.getItem("waitingreserves_activetab"); + if( activeTab ){ + $("div#resultlist li:eq(" + activeTab + ") a").tab("show"); + } } $("div#resultlist a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) { var thisTab = $(e.target).parent(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index eef3e3fbbea..c32de6ab9bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -271,7 +271,7 @@ [% IF holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions %]
- Holds with cancellation requests: + Holds with cancellation requests: [% holds_with_cancellation_requests | html %]
[% END %] -- 2.47.0