From eadf58c5580ddefce0a9b3017b00200551bf33b0 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. Signed-off-by: Barbara Johnson Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/css/addbiblio.css | 14 +- .../en/modules/authorities/authorities.tt | 431 +++++++++--------- 2 files changed, 226 insertions(+), 219 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css index c84f399ab7..4411026906 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css +++ b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css @@ -6,17 +6,23 @@ div#toolbar { border: 0; } -#addbibliotabs .ui-tabs-nav, -#authoritytabs .ui-tabs-nav { +#addbibliotabs .ui-tabs-nav { display: none; } -.ui-tabs-panel h3 { +.tab-content { + border: 0; + padding: 0; +} + +.ui-tabs-panel h3, +.tab-pane h3 { font-size: 140%; margin: .3em 0; } -.ui-tabs-panel ul { +.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..0ce0cc5d6e 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,9 +56,10 @@ } return false; }); + $(".toolbar-tabs a").on("click",function(e){ e.preventDefault(); - selectTab( $(this ) ); + selectTab( this.hash ); }); $(".tag_anchor").on("click", function(e){ @@ -81,10 +82,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 +331,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.30.2