From 4dbd9083aa27d48a73fbda8d5d153276b9a8b778 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 5 Oct 2022 19:08:24 +0000 Subject: [PATCH] Bug 31678: Convert authority editor tabs to Bootstrap This patch modifies the authorities editor template to replace jQueryUI tabs with Bootstrap tabs. The changes should have no visible effect, with all previous functionality still intact. To test, apply the patch and go to Authorities -> New authority. - When the page first displays, the "0" tab should be active. - Test that each of the numbered tabs works correctly to activate the correct tab content. - Confirm that the numbered tag anchors still work correctly. - Append a specific tab anchor to the URL, e.g. "#tab4XX" and refresh the page (you may need to shift-refresh). When the page reloads the correct tab should be active by default. - Confirm that sortable subfields can still be re-ordered by dragging and dropping them via the "stacked lines" icons. --- .../intranet-tmpl/prog/css/addbiblio.css | 10 +- .../en/modules/authorities/authorities.tt | 432 +++++++++--------- 2 files changed, 219 insertions(+), 223 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css index c84f399ab7..ef5d7284e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css +++ b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css @@ -6,17 +6,17 @@ div#toolbar { border: 0; } -#addbibliotabs .ui-tabs-nav, -#authoritytabs .ui-tabs-nav { - display: none; +.tab-content { + border: 0; + padding: 0; } -.ui-tabs-panel h3 { +.tab-pane h3 { font-size: 140%; margin: .3em 0; } -.ui-tabs-panel ul { +.tab-pane ul { margin-bottom: 0; padding-left: 0; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index 548b841aa1..c8da87262e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -21,23 +21,23 @@ }); var Sticky; $(document).ready(function() { - var tabs = $('#authoritytabs').tabs({ - activate: function(e, ui) { - $("#"+ $(ui.newPanel).attr("id") + " .input_marceditor:visible:eq(0)").focus(); - } - }); + + $("a[data-toggle='tab']").on("shown.bs.tab", function (e) { + $( e.target.hash + " .input_marceditor:visible:eq(0)").focus(); + }); /* On page load, check for location.hash in the page URL */ + /* If present the location hash will be used to activate the correct tab */ var hash = location.hash; var hashPieces = hash.split('?'); if( hashPieces[0] !== "" ){ - var activeTab = $("[href='" + hashPieces[0] + "']"); - selectTab(activeTab); + selectTab( hashPieces[0] ); window.scrollTo( 0, 0 ); } - $( "ul.sortable_field", tabs ).sortable(); - $( "ul.sortable_subfield", tabs ).sortable(); + $( "ul.sortable_field", "#authoritytabs" ).sortable(); + $( "ul.sortable_subfield", "#authoritytabs" ).sortable(); + Sticky = $("#toolbar"); Sticky.hcSticky({ stickTo: ".main", @@ -56,10 +56,6 @@ } return false; }); - $(".toolbar-tabs a").on("click",function(e){ - e.preventDefault(); - selectTab( $(this ) ); - }); $(".tag_anchor").on("click", function(e){ e.preventDefault(); @@ -81,10 +77,10 @@ }); function selectTab( tablink ){ + let a = $("a[href='" + tablink + "']"); $(".toolbar-tabs li").removeClass("selected"); - tablink.parent().addClass("selected"); - var tabid = tablink.data("tabid"); - $('#authoritytabs').selectTabByID("#tab" + tabid + "XX"); + a.tab("show").parent().addClass("selected"); + var tabid = a.data("tabid"); $(".tag_anchors").removeClass("tab_selected").hide(); $(".tag_anchors_" + tabid ).addClass("tab_selected").show(); } @@ -330,14 +326,14 @@
[% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %] -
- - - [% FOREACH BIG_LOO IN BIG_LOOP %] -
- [% IF ( BIG_LOOP.size > 1 ) %] -

Section [% BIG_LOO.number | html %]

+ [% IF loop.first %] +
+ [% ELSE %] +
[% END %] - [% previous = "" %] - [% FOREACH innerloo IN BIG_LOO.innerloop %] - [% IF ( innerloo.tag ) %] - [% IF innerloo.tag != previous %] - [% IF previous != "" %] - + [% IF ( BIG_LOOP.size > 1 ) %] +

Section [% BIG_LOO.number | html %]

+ [% END %] + [% previous = "" %] + [% FOREACH innerloo IN BIG_LOO.innerloop %] + [% IF ( innerloo.tag ) %] + [% IF innerloo.tag != previous %] + [% IF previous != "" %] + + [% END %] + [% previous = innerloo.tag %] + [% IF ( innerloo.repeatable ) %] +
    + [% ELSE %] +
      + [% END %] [% END %] - [% previous = innerloo.tag %] + [% IF ( innerloo.repeatable ) %] -
        +
      • [% ELSE %] -
          +
        • [% END %] - [% END %] - [% IF ( innerloo.repeatable ) %] -
        • - [% ELSE %] -
        • - [% END %] - -
          - [% UNLESS hide_marc %] - [% IF advancedMARCEditor %] - [% innerloo.tag | html %] +
          + [% UNLESS hide_marc %] + [% IF advancedMARCEditor %] + [% innerloo.tag | html %] + [% ELSE %] + [% innerloo.tag | html %] + [% END %] + [% IF ( innerloo.fixedfield ) %] + + + [% ELSE %] + + + [% END # /IF ( innerloo.fixedfield ) %] - [% ELSE %] - [% innerloo.tag | html %] + [% IF ( innerloo.fixedfield ) %] + + + [% ELSE %] + + + [% END # /IF ( innerloo.fixedfield ) %] + [% END # /UNLESS hide_marc %] + + [% UNLESS advancedMARCEditor %] + [% innerloo.tag_lib | html %] [% END %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END # /IF ( innerloo.fixedfield ) %] - - [% ELSE %] - [% IF ( innerloo.fixedfield ) %] - - - [% ELSE %] - - - [% END # /IF ( innerloo.fixedfield ) %] - [% END # /UNLESS hide_marc %] - - [% UNLESS advancedMARCEditor %] - [% innerloo.tag_lib | html %] - [% END %] - - [% IF ( innerloo.repeatable ) %] - - Repeat this Tag + + [% IF ( innerloo.repeatable ) %] + + Repeat this Tag + + [% END %] + + Delete this Tag - [% END %] - - Delete this Tag - - -
          - -
            - [% FOREACH subfield_loo IN innerloo.subfield_loop %] - -
          • - - [% UNLESS hide_marc %] -
            - +
            + +
              + [% FOREACH subfield_loo IN innerloo.subfield_loop %] + +
            • + + [% UNLESS hide_marc %] +
              + +
              + [% ELSE %] + -
          - [% ELSE %] - - [% END # /UNLESS hide_marc %] + value="[% subfield_loo.subfield | html %]" /> + [% END # /UNLESS hide_marc %] - [% UNLESS advancedMARCEditor %] - [% IF ( subfield_loo.mandatory ) %] -
          - [% ELSE %] -
          - [% END %] - [% IF ( subfield_loo.fixedfield ) %] -
        • - [% END # /FOREACH subfield_loo %] -
        -
      • - [% END # /IF ( innerloo.tag ) %] - [% END # /FOREACH innerloo %] -
      -
- [% END #/FOREACH BIG_LOO %] + [% IF ( subfield_loo.mandatory ) %] +
+ Required +
+ [% END %] + +
+ [% IF ( mv.type == 'text1' ) %] + Tag editor + [% ELSIF ( mv.type == 'text2' ) %] + [% IF mv.noclick %] + ... + [% ELSE %] + ... + [% END %] + [% mv.javascript | $raw %] + [% END #/IF ( mv.type == 'text1' ) %] + [% IF ( subfield_loo.repeatable ) %] + + Clone + + + Delete + + [% END # /IF ( subfield_loo.repeatable ) %] +
+ + [% END # /FOREACH subfield_loo %] + + + [% END # /IF ( innerloo.tag ) %] + [% END # /FOREACH innerloo %] + +
+ [% END #/FOREACH BIG_LOO %] +
-- 2.20.1