From 9a0723db674ecd8a4f3b3eb2e88c20a543ea7a6b 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. --- .../prog/en/modules/circ/waitingreserves.tt | 14 +++++++++++--- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- 2 files changed, 12 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 75f50f1f64..b2facb643b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -299,10 +299,18 @@ }); }); - 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-toggle='tab']").on("shown.bs.tab", function (e) { var thisTab = $(e.target).parent(); var activeTab = thisTab.index(); 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 354f8c73c2..6a1e972833 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -278,7 +278,7 @@ [% END %] [% 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.30.2