From f9d7ae6670d00ea88de6d5bc3ec3f1c800ca712a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 11 Apr 2022 12:00:38 +0000 Subject: [PATCH] Bug 30489: Convert MARC and authority subfield edit tabs to Bootstrap This patch updates the MARC and authority subfield edit interface to replace jQueryUI tabs with Bootstrap. The code for handling drag-to-reorder tabs is updated to accommodate the new markup. To test, apply the patch and restart_all. - Go to Administration -> MARC bibliographic framework -> Default framework and choose "MARC structure" from the Actions menu. - In the row for 000 LEADER, click Actions -> View subfields. - Click "Edit." On the edit page the tabs should look correct and work correctly. - Return to the list of tags and click "View subfields" for the 245 tag. - Click one of the "Edit" buttons for any but the first subfield, e.g. "a". - On the "Tag 245 Subfield constraints" page the "a" tab should be pre-selected. - Click any of the subfield tabs and drag it to re-order it in the sequence of tags. - It should stay in the correct slot when you release it. - Save and confirm that the new sequence of subfields has been saved. Perform all the same tests under Administration -> Authority types. --- admin/auth_subfields_structure.pl | 2 +- admin/marc_subfields_structure.pl | 1 + .../modules/admin/auth_subfields_structure.tt | 337 ++++++++-------- .../modules/admin/marc_subfields_structure.tt | 369 +++++++++--------- .../prog/js/marc_subfields_structure.js | 21 +- 5 files changed, 387 insertions(+), 343 deletions(-) diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index aec16d3f22..2198561752 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -138,7 +138,7 @@ if ($op eq 'add_form') { $template->param('heading_edit_subfields_p' => 1); $template->param(action => "Edit subfields", tagfield => $tagfield, - tagfieldinput => "", + tagsubfield => $tagsubfield, loop => \@loop_data, more_tag => $tagfield); diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index cf8e16462f..a2117eb912 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -199,6 +199,7 @@ if ( $op eq 'add_form' ) { $template->param( action => "Edit subfields", tagfield => $tagfield, + tagsubfield => $tagsubfield, loop => \@loop_data, more_tag => $tagfield ); 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 67eee4f1ab..e7a4045c0b 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 @@ -87,182 +87,195 @@
Cancel
+ + [% BLOCK outputsubfield %][% FILTER collapse %] + [% SWITCH ( subfieldanchor ) %] + [% CASE "@" %] + AT + [% CASE "%" %] + % + [% CASE %] + [% subfieldanchor | html %] + [% END %] + [% END %][% END %] +
-
[% END %] @@ -310,7 +323,7 @@ [% FOREACH loo IN loop %] - [% loo.tagsubfield | html %] + [% loo.tagsubfield | html %] [% IF loo.tab == -1 %] @@ -341,7 +354,7 @@ [% END %] - Edit + Edit Delete @@ -382,9 +395,16 @@ paginate: false })); - var tabs = $('#subfieldtabs').tabs(); + [% 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 %] + var current_index; - tabs.find( ".ui-tabs-nav" ).sortable({ + $("#subfieldtabs > ul").sortable({ axis: "x", start: function (e, ui) { current_index = $(ui.item[0]).index(); @@ -394,13 +414,12 @@ if (current_index < new_index) new_index++; var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, ''); var content = $('#sub' + subfield_code + 'field'); - var panels = $("#subfieldtabs > div"); + var panels = $("#subfieldtabs .tab-pane"); if ( new_index < $(panels).size() ){ - $(content).insertBefore($("#subfieldtabs > div")[new_index]); + $(content).insertBefore( panels[new_index]); } else { - $(content).insertAfter($("#subfieldtabs > div")[new_index-1]); + $(content).insertAfter( panels[new_index-1]); } - tabs.tabs("refresh"); } }); 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 881adf1a3e..0ac23a9172 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 @@ -124,14 +124,25 @@ + [% BLOCK outputsubfield %][% FILTER collapse %] + [% SWITCH ( subfieldanchor ) %] + [% CASE "@" %] + AT + [% CASE "%" %] + % + [% CASE %] + [% subfieldanchor | html %] + [% END %] + [% END %][% END %] +
-
@@ -399,7 +413,7 @@ [% END %] - Edit + Edit Delete @@ -431,6 +445,9 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% 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 2da2eb1461..898c64e3ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js @@ -1,8 +1,15 @@ -/* global dataTablesDefaults */ +/* global dataTablesDefaults tagsubfield */ $(document).ready(function() { - var tabs = $('#subfieldtabs').tabs(); + if( tagsubfield && tagsubfield == "@"){ + $("#subfieldtabs a[href='#subATfield']").tab("show"); + } else if ( tagsubfield && tagsubfield != "@"){ + $("#subfieldtabs a[href='#sub" + tagsubfield + "field'").tab("show"); + } else { + $("#subfieldtabs a:first").tab("show"); + } + var current_index; - tabs.find( ".ui-tabs-nav" ).sortable({ + $("#subfieldtabs > ul").sortable({ axis: "x", start: function (e, ui) { current_index = $(ui.item[0]).index(); @@ -12,15 +19,15 @@ $(document).ready(function() { if (current_index < new_index) new_index++; var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, ''); var content = $('#sub' + subfield_code + 'field'); - var panels = $("#subfieldtabs > div"); + var panels = $("#subfieldtabs .tab-pane"); if ( new_index < $(panels).size() ){ - $(content).insertBefore($("#subfieldtabs > div")[new_index]); + $(content).insertBefore( panels[new_index]); } else { - $(content).insertAfter($("#subfieldtabs > div")[new_index-1]); + $(content).insertAfter( panels[new_index-1]); } - tabs.tabs("refresh"); } }); + $("input[id^='hidden_']").click(setHiddenValue); $("input[id^='hidden-']").each(function() { populateHiddenCheckboxes($(this).attr('id').split('-')[1]); -- 2.20.1