From 1c193268b7a6de68de0c766b3d352d503bd8adbe 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 --- .../prog/en/modules/tools/letter.tt | 219 +++++++++++------- koha-tmpl/intranet-tmpl/prog/js/letter.js | 37 +-- tools/letter.pl | 4 +- 3 files changed, 158 insertions(+), 102 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 f2337e39e9..7997752a30 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,112 +439,134 @@ [% 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 84e63c9d96..3eeee72a57 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/letter.js +++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js @@ -128,20 +128,31 @@ $(document).ready(function() { } }); - $( ".transport-types" ).accordion({ - 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 +164,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.30.2