From 7f87001bde374b87c9063acfdedd1b6fc7139b88 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 8 Apr 2022 12:20:00 +0000 Subject: [PATCH] Bug 30545: Replace the use of jQueryUI Accordion on the notices page This patch updates the notices edit interface in order to replace jQueryUI accordion and tabs widgets with Bootstrap collapse and tabs. To test, apply the patch and rebuild the staff interface CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). - Set the TranslateNotices system preference to "Don't allow." - Go to Tools -> Notices and edit any notice. - On the "Modify notice" page you should see three collapsed sections: Email, Print, and SMS. - Clicking the section headings should expand and collapse the panels. - With one of the panels open, click Save -> Save and continue editing. - When the page reloads the same panel should be expanded. - Enable the TranslateNotices system preference. - Return to the edit interface for one of your notices. - You should now see at least two tabs: Default and English. - The sections under each tab should continue to work correctly. - Test the "Save and continue" functionality again. When redirected you should return to both the correct tab and the correct panel, e.g. the "Print" section under the "English (en)" tab. Signed-off-by: Lucas Gass Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- .../prog/en/modules/tools/letter.tt | 205 +++++++++++------- koha-tmpl/intranet-tmpl/prog/js/letter.js | 38 ++-- tools/letter.pl | 4 +- 3 files changed, 151 insertions(+), 96 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 5df167339d..4547611965 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -22,7 +22,30 @@ Notices › Tools › Koha [% INCLUDE 'doc-head-close.inc' %] - +[% FILTER collapse %] + +[% END %] @@ -416,105 +439,127 @@ [% IF Koha.Preference('TranslateNotices') %]
-
+ [% END # /FOR mtt %] + + [% END # /FOREACH lang %] [% IF Koha.Preference('TranslateNotices') %] - + + [% END %] + [% END # /IF add_form %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js index 7ab4f7f46d..76b2d497fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/letter.js +++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js @@ -127,21 +127,31 @@ $(document).ready(function() { } }); - $( ".transport-types" ).accordion({ - header: "h3", - collapsible: true, - active: parseInt( $("#section").val(), 10), - animate: 200, - activate: function() { - var active = $( ".transport-types" ).accordion( "option", "active" ); - if( active === false ){ - $("#section").val(""); - } else { - $("#section").val( active ); - } - } + let section = $("#section").val(); + if( section != "" ){ + $("a[href='#" + section + "']").click(); + } + + $(".panel-group").on("shown.bs.collapse", function (e) { + $("#section").val( e.target.id ); + }).on("hidden.bs.collapse", function (e) { + $("#section").val(""); }); + if( $("#tabs").length > 0 ){ + let langtab = $("#langtab").val(); + $("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) { + var link = e.target.hash.replace("#",""); + $("#langtab").val( link ); + }); + + if( langtab != "" ){ + $("#tabs a[href='#" + langtab + "']").tab("show"); + } else { + $("#tabs a:first").tab("show"); + } + } + $(".insert").on("click",function(){ var containerid = $(this).data("containerid"); insertValueQuery( containerid ); @@ -153,8 +163,6 @@ $(document).ready(function() { $("#submit_form").click(); }); - $("#tabs").tabs(); - $("body").on("click", ".preview_template", function(e){ e.preventDefault(); var mtt = $(this).data("mtt"); diff --git a/tools/letter.pl b/tools/letter.pl index 1b6f39ae89..4276e46280 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -70,6 +70,7 @@ my $content = $input->param('content'); my $op = $input->param('op') || ''; my $redirect = $input->param('redirect'); my $section = $input->param('section'); +my $langtab = $input->param('langtab'); my $dbh = C4::Context->dbh; @@ -93,13 +94,14 @@ $template->param( searchfield => $searchfield, branchcode => $branchcode, section => $section, + langtab => $langtab, action => $script_name ); if ( $op eq 'add_validate' or $op eq 'copy_validate' ) { add_validate(); if( $redirect eq "just_save" ){ - print $input->redirect("/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=$branchcode&module=$module&code=$code&redirect=done§ion=$section"); + print $input->redirect("/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=$branchcode&module=$module&code=$code&redirect=done§ion=$section&langtab=$langtab"); exit; } else { $op = q{}; # we return to the default screen for the next operation -- 2.20.1