From e5b206b3dd24275cc02e09623216b16331ed04b2 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. Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- 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 d6b77237d8..67222253cc 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 %] +
-
    + +
    + [% FOREACH loo IN loop %] +
    +
      - [% FOREACH loo IN loop %] -
      -
        - - [% IF ( loo.new_subfield ) %] -
      1. - - -
      2. - [% ELSE %] -
      3. - -
      4. - [% END %] -
      5. - - [% IF loo.repeatable %] - - [% ELSE %] - - [% END %] -
      6. -
      7. - - [% IF loo.mandatory %] - - [% ELSE %] - - [% END %] -
      8. -
      9. -
      10. -
      11. - -
        Ignore means that the subfield does not display in the record editor
        -
      12. -
      13. -
        - Display -
          -
        1. - -
        2. -
        -
        -
      14. -
      15. -
        - Advanced constraints: -
          + [% IF ( loo.new_subfield ) %] +
        1. + + +
        2. + [% ELSE %] +
        3. + +
        4. + [% END %]
        5. - - [% IF loo.isurl %] - + + [% IF loo.repeatable %] + [% ELSE %] - + [% END %] - If checked, it means that the subfield is a URL and can be clicked.
        6. - - + + [% IF loo.mandatory %] + + [% ELSE %] + + [% END %]
        7. -
        -
        -
      16. -
      17. -
        Help input -
          -
        1. - -
        2. +
        3. +
        4. + -
        5. -
        6. - - +
          Ignore means that the subfield does not display in the record editor
        7. - - +
          + Display +
            +
          1. + +
          2. +
          +
        8. - - +
          + Advanced constraints: +
            +
          1. + + [% IF loo.isurl %] + + [% ELSE %] + + [% END %] + If checked, it means that the subfield is a URL and can be clicked. +
          2. +
          3. + + +
          4. +
          +
        9. -
        -
        -
      18. -

      -
      - [% END %] +
    1. +
      Help input +
        +
      1. + + +
      2. +
      3. + + +
      4. +
      5. + + +
      6. +
      7. + + +
      8. +
      +
      +
    2. +

    +
    + [% 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 4baa81201e..7970d63051 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 %] +
-
    + - [% FOREACH loo IN loop %] -
    -
    -
    - Basic constraints -
      - [% IF ( subfieldcode == 0 || subfieldcode ) %] -
    1. - Subfield code: - [% loo.subfieldcode | html %] -
    2. - [% ELSE %] -
    3. - - +
      + + [% FOREACH loo IN loop %] +
      +
      +
      + Basic constraints +
        + [% IF ( subfieldcode == 0 || subfieldcode ) %] +
      1. + Subfield code: + [% loo.subfieldcode | html %]
      2. - [% END %] -
      3. - - -
      4. -
      5. - - -
      6. -
      7. - - [% IF loo.repeatable %] - [% ELSE %] - +
      8. + + +
      9. [% END %] - -
      10. - - [% IF loo.mandatory %] - - [% ELSE %] - - [% END %] -
      11. -
      12. - - [% IF loo.important %] - - [% ELSE %] - - [% END %] -
      13. -
      14. - +
      15. +
      16. + + +
      17. +
      18. + + [% IF loo.repeatable %] + + [% ELSE %] + + [% END %] +
      19. +
      20. + + [% IF loo.mandatory %] + + [% ELSE %] + + [% END %] +
      21. +
      22. + + [% IF loo.important %] + + [% ELSE %] + + [% END %] +
      23. +
      24. + -
        Ignore means that the subfield does not display in the record editor
        -
      25. -
      -
      -
      - -
      -
      - Advanced constraints -
        -
      1. - - -
      2. -
      3. - - -
      4. -
      5. - [% IF loo.hidden_protected %] - - [% ELSE %] - - [% END %] - - - - - - - - - - - -
      6. -
      7. - - [% IF loo.isurl %] - - [% ELSE %] - - [% END %] - If checked, it means that the subfield is a URL and can be clicked -
      8. -
      9. - - -
        An index name, e.g. title or Local-Number
        -
      10. -
      11. - - - - - -
      12. -
      -
      -
      - -
      -
      - Other options (choose one) -
        -
      1. - - +
        Ignore means that the subfield does not display in the record editor
        +
      2. +
      +
      +
      + +
      +
      + Advanced constraints +
        +
      1. + + +
      2. +
      3. + + +
      4. +
      5. + [% IF loo.hidden_protected %] + [% ELSE %] - + [% END %] - [% END %] - -
      6. -
      7. - - + + + + + + + + + +
      8. +
      9. + + [% IF loo.isurl %] + [% ELSE %] - + [% END %] - [% END %] - -
      10. -
      11. - - +
        An index name, e.g. title or Local-Number
        +
      12. +
      13. + + + -
      14. -
      -
      -
      -
      - [% END # /FOREACH loo %] + [% END %] + + + +
    4. +
    +
    +
    + +
    +
    + Other options (choose one) +
      +
    1. + + +
    2. +
    3. + + +
    4. +
    5. + + +
    6. +
    +
    +
    +
    + [% END # /FOREACH loo %] +
@@ -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.39.5