From 2fa6c105b1a319ce79305aef4b8c3115029ad504 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 (cherry picked from commit 72364bb34cf6c427adf62486cfdcc6f65bcfb9d8) Signed-off-by: Matt Blenkinsop --- 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 | 7 ++----- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 11 +++++++++++ 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index a5538a58cf..4d311cff7c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -1212,9 +1212,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 a320df7c5f..00802c178f 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 0760a072d5..66fb1baf86 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 b628b3951c..05d626af01 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js @@ -1,3 +1,4 @@ +/* global borrowernumber selectBsTabByHash */ $(document).ready(function() { $("#CheckAllExports").on("click",function(){ $(".export:visible").prop("checked", true); @@ -90,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"); }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 0e16baf053..4dd719da0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -595,3 +595,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.2