From 72364bb34cf6c427adf62486cfdcc6f65bcfb9d8 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 23 Jun 2023 16:02:43 +0000 Subject: [PATCH] Bug 34115: Use a global tab select function for activating Bootstrap tabs based on location hash This patch fixes automatic tab selection by location.hash in the MARC subfield editor. This allows links which target a specific subfield to open the page with the subfield tab selected. I've put this into a global function since it can be reused in multiple places: The about page and the checkout page have variations of this functionality which can be replaced with this function. The patch also corrects two links in Koha pointing to the About page which included the wrong location hash (changed in the switch to Bootstrap tab wrappers). To test, apply the patch and go to Adminstration -> Bibliographic frameworks. - View the MARC structure for any framework. - In the "Search for tag" input field, submit a tag and subfield which will be found in that framework, e.g. "245$a" - When you submit the form you should be sent to the MARC subfield structure page for that tag with the subfield tab automatically selected. - View the MARC subfield structure for any framework. - In the table of subfields, click the subfield link in the first column. You should be taken to the edit form with the corresponding tab selected. - Go to Circulation and check out to a patron. Append a tab anchor to the URL, e.g. "#holds_panel" and submit. You may have to shift-reload the page to see the change. (As far as I know no links in Koha take advantage of this) - Perform the same test on the patron detail page - Go to the About page and perform the same test with a tab anchor like "#team_panel" or "#sysinfo_panel" Signed-off-by: Sam Lau Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit cb6dd4e82be67977c5f58f10639a0e6f39219c0e) Signed-off-by: Fridolin Somers --- koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 4 +--- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 2 +- .../intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 2 +- .../intranet-tmpl/prog/js/marc_subfields_structure.js | 5 ++++- koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js | 8 ++------ koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 11 +++++++++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 87e9a409cb..d3d3596f4b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -1218,9 +1218,7 @@ [% MACRO jsinclude BLOCK %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 1e1e11a1da..161c336cbb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -371,7 +371,7 @@

Reminder: Patron has an indefinite restriction.

[% END %] [% IF errmsgloo.data_corrupted %] -

The item has not been checked in due to a configuration issue in your system. You must ask an administrator to take a look at the about page and correct all errors shown on the "System information" tab

+

The item has not been checked in due to a configuration issue in your system. You must ask an administrator to take a look at the about page and correct all errors shown on the "System information" tab

[% END %] [% END # /FOREACH errmsgloo %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index a5ade70cb3..f8ab75e57d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -111,7 +111,7 @@ [% END %]
[% IF !backends_available || !has_branch %] -
ILL module configuration problem. Take a look at the about page
+
ILL module configuration problem. Take a look at the about page
[% ELSE %] [% INCLUDE 'ill-toolbar.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js index 898c64e3ae..119507ba01 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js @@ -1,4 +1,4 @@ -/* global dataTablesDefaults tagsubfield */ +/* global dataTablesDefaults tagsubfield selectBsTabByHash */ $(document).ready(function() { if( tagsubfield && tagsubfield == "@"){ $("#subfieldtabs a[href='#subATfield']").tab("show"); @@ -39,6 +39,9 @@ $(document).ready(function() { aaSorting: [], paginate: false })); + + selectBsTabByHash("subfieldtabs"); + }); /* Function to enable/disable hidden values checkboxes when Flag is (de)selected */ diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js index 7a8f53f474..d05d87b5bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js @@ -1,4 +1,4 @@ -/* global borrowernumber */ +/* global borrowernumber selectBsTabByHash */ $(document).ready(function() { $("#CheckAllExports").on("click",function(){ $(".export:visible").prop("checked", true); @@ -91,11 +91,7 @@ $(document).ready(function() { }); /* Preselect Bootstrap tab based on location hash */ - var hash = window.location.hash.substring(1); - if( hash ){ - var activeTab = $('a[href="#' + hash + '"]'); - activeTab && activeTab.tab('show'); - } + selectBsTabByHash("finesholdsissues"); if ( $('#clubs_panel').length ) { $('#clubs-tab').on('click', function() { diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index abb3193bd7..56e35b6209 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -598,3 +598,14 @@ function buildPatronSearchQuery(term, options) { } return q; } + +function selectBsTabByHash( tabs_container_id ){ + /* Check for location.hash in the page URL */ + /* If present the location hash will be used to activate the correct tab */ + var hash = document.location.hash; + if( hash !== "" ){ + $('#' + tabs_container_id + ' a[href="' + hash + '"]').tab('show'); + } else { + $('#' + tabs_container_id + ' a:first').tab('show'); + } +} -- 2.39.5