From e1c9346db0e73c684b9fcd1c5202598e68e95854 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 3af7bf9861..10e0eedda2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -300,10 +300,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 9e51c8ab3e..ffe321850c 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.39.2