From 483f08426e9ba1cc542cd4d4f8e6237a5673ba49 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 12 Feb 2026 09:34:45 -0500 Subject: [PATCH] Bug 41838: Fix automatic tab selection on MARC subfield edit pages This patch fixes automatic tab selection on MARC subfield edit pages for both authority and bibliographic records. The patch also removes some unused markup and JS associated with old ways of handling tabs. To test, apply the patch and go to Administration -> Authority types. - Click the "Actions" button for one of the authority types and select "MARC structure" - Pick a tag which has multiple subfields, e.g. 020 and click Actions -> Subfields. - Click one of the subfield links (not the first one). On the subfield edit page the corresponding tab should be selected when the page loads. - Go back and click the "Edit" button and confirm that this also selects the correct tab. - Go to Administration -> MARC bibliographic framework -> MARC structure -> View subfields and perform the same tests. Sponsored-by: Athens County Public Libraries --- .../modules/admin/auth_subfields_structure.tt | 8 +-- .../modules/admin/marc_subfields_structure.tt | 6 +-- .../prog/js/marc_subfields_structure.js | 52 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt index 18a88a77bd6..3ffb773e4be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt @@ -361,7 +361,9 @@ [% FOREACH loo IN loop %] - [% loo.tagsubfield | html %] + [% loo.tagsubfield | html %] [% IF loo.tab == -1 %] @@ -401,9 +403,7 @@ [% END %] - Edit [% loo.tagsubfield | html %] @@ -405,7 +405,7 @@ Edit @@ -439,7 +439,7 @@ [% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %] [% Asset.js("js/admin-menu.js") | $raw %] [% Asset.js("js/marc_subfields_structure.js") | $raw %] [% END %] 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 3cf5d8053c8..783e21ca6ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js @@ -1,29 +1,31 @@ -/* global tagsubfield selectBsTabByHash */ +/* global tagsubfield */ $(document).ready(function () { - if (tagsubfield && tagsubfield == "@") { - $("#subfieldtabs a[href='#AT_panel']").tab("show"); - } else if (tagsubfield && tagsubfield != "@") { - $("#subfieldtabs a[href='#" + tagsubfield + "_panel'").tab("show"); - } else { - $("#subfieldtabs a:first").tab("show"); - } + if ($("#subfieldtabs").length > 0) { + if (tagsubfield && tagsubfield == "@") { + $("#subfieldtabs a[href='#AT_panel']").tab("show"); + } else if (tagsubfield && tagsubfield != "@") { + $(`#subfieldtabs a[href='#${tagsubfield}_panel']`).tab("show"); + } else { + $("#subfieldtabs a:first").tab("show"); + } - var subfields_list = $("#subfieldtabs > ul"); - var sortable_subfields = new Sortable(subfields_list[0], { - onEnd: function (e) { - var old_index = e.oldIndex; - var new_index = e.newIndex; - if (old_index < new_index) new_index++; - var subfield_code = e.item.id.replace(/^tab_subfield_/, ""); - var content = $("#" + subfield_code + "_panel"); - var panels = $("#subfieldtabs .tab-pane"); - if (new_index < $(panels).size()) { - $(content).insertBefore(panels[new_index]); - } else { - $(content).insertAfter(panels[new_index - 1]); - } - }, - }); + var subfields_list = $("#subfieldtabs > ul"); + var sortable_subfields = new Sortable(subfields_list[0], { + onEnd: function (e) { + var old_index = e.oldIndex; + var new_index = e.newIndex; + if (old_index < new_index) new_index++; + var subfield_code = e.item.id.replace(/^tab_subfield_/, ""); + var content = $("#" + subfield_code + "_panel"); + var panels = $("#subfieldtabs .tab-pane"); + if (new_index < $(panels).size()) { + $(content).insertBefore(panels[new_index]); + } else { + $(content).insertAfter(panels[new_index - 1]); + } + }, + }); + } $("input[id^='hidden_']").click(setHiddenValue); $("input[id^='hidden-']").each(function () { @@ -33,8 +35,6 @@ $(document).ready(function () { order: [], paging: false, }); - - selectBsTabByHash("subfieldtabs"); }); /* Function to enable/disable hidden values checkboxes when Flag is (de)selected */ -- 2.39.5