From e375481e3d8e1dc05f4fadda4f1f78c6f926228b Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 6 Jun 2024 15:10:21 +0000 Subject: [PATCH] Bug 33178: Use template wrapper for authority and bibliographic subfield entry form tabs This patch updates the authority and bibliographic subfield entry forms to replace tab markup with the use of WRAPPERs. Some JS has been modified in order to adapt to the changed Bootstrap tab markup. The patch also updates the WRAPPER code so that a unique ID can be added to individual tabs. This is necessary as a hook for the Sortable JavaScript. To test, apply the patch and go to Administration. - Go to MARC bibliographic frameworks -> Actions -> MARC structure. - Click Actions -> View subfields for a tag with more than one subfield. - Click the "Edit" button for one of the subfields, not the first one in the list. - The tab for the subfield you chose should be active. - Confirm that all the tabs look correct and work correctly. - Try dragging one of the tabs into a new position. Save your changes and confirm that the subfield was saved in that new position. - Go to Administration -> Authority types -> Actions -> MARC structure and repeat the same steps above with the authority record subfields. Sponsored-By: Athens County Public Libraries Signed-off-by: Phil Ringnalda Signed-off-by: Paul Derscheid Signed-off-by: Katrin Fischer --- .../prog/en/includes/html_helpers.inc | 6 +- .../modules/admin/auth_subfields_structure.tt | 79 ++++++++++--------- .../modules/admin/marc_subfields_structure.tt | 41 +++++----- .../prog/js/marc_subfields_structure.js | 6 +- 4 files changed, 70 insertions(+), 62 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc index 16736e5c1a..4ff81a0a70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -388,7 +388,11 @@ [% END %] [% BLOCK tab_item %] -
- - [% END %] - - + [% END # /WRAPPER tab_panel %] + [% END # /FOREACH loo %] + [% END # /WRAPPER tab_panels %] + [% END # /WRAPPER tabs %] [% END %] @@ -415,30 +418,32 @@ paginate: false })); - [% IF ( tagsubfield && tagsubfield == "@") %] - $("#subfieldtabs a[href='#subATfield']").tab("show"); - [% ELSIF ( tagsubfield && tagsubfield != "@") %] - $("#subfieldtabs a[href='#sub[% tagsubfield | html %]field']").tab("show"); - [% ELSE %] - $("#subfieldtabs a:first").tab("show"); - [% END %] + if( $("#subfieldtabs").length > 0 ){ + [% IF ( tagsubfield && tagsubfield == "@") %] + $("#subfieldtabs a[href='#AT_panel']").tab("show"); + [% ELSIF ( tagsubfield && tagsubfield != "@") %] + $("#subfieldtabs a[href='#[% tagsubfield | html %]_panel']").tab("show"); + [% ELSE %] + $("#subfieldtabs a:first").tab("show"); + [% END %] - 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 = $('#sub' + subfield_code + 'field'); - 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]); + } } - } - }); + }); + } }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt index 1e0c80eb5c..105e0b7531 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt @@ -110,27 +110,26 @@ [% END %] [% END %][% END %] -
- - -
+ [% loo.subfieldcode | html %] + [% END # IF loo.new_subfield%] + [% END # WRAPPER tab_item %] + [% END # FOREACH loo %] + [% END # /WRAPPER tabs_nav %] + [% WRAPPER tab_panels %] [% FOREACH loo IN loop %] -
+ [% outputsubfield = PROCESS outputsubfield subfieldanchor = loo.subfieldcode %] + [% WRAPPER tab_panel tabname=outputsubfield %] -
+
Basic constraints
    @@ -204,7 +203,7 @@
-
+
Advanced constraints
    @@ -260,7 +259,7 @@
-
+
Other options (choose one)
    @@ -303,11 +302,11 @@
-
-
+
+ [% END # /WRAPPER tab_panel %] [% END # /FOREACH loo %] -
-
+ [% END # /WRAPPER tab_panels %] + [% END # /WRAPPER tabs %]
Cancel 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 19b5ff51a3..fb164b4c11 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js @@ -1,9 +1,9 @@ /* global dataTablesDefaults tagsubfield selectBsTabByHash */ $(document).ready(function() { if( tagsubfield && tagsubfield == "@"){ - $("#subfieldtabs a[href='#subATfield']").tab("show"); + $("#subfieldtabs a[href='#AT_panel']").tab("show"); } else if ( tagsubfield && tagsubfield != "@"){ - $("#subfieldtabs a[href='#sub" + tagsubfield + "field'").tab("show"); + $("#subfieldtabs a[href='#" + tagsubfield + "_panel'").tab("show"); } else { $("#subfieldtabs a:first").tab("show"); } @@ -15,7 +15,7 @@ $(document).ready(function() { var new_index = e.newIndex; if (old_index < new_index) new_index++; var subfield_code = e.item.id.replace( /^tab_subfield_/, ''); - var content = $('#sub' + subfield_code + 'field'); + var content = $( '#' + subfield_code + '_panel'); var panels = $("#subfieldtabs .tab-pane"); if ( new_index < $(panels).size() ){ $(content).insertBefore( panels[new_index]); -- 2.39.5