From 225a6747f0556bd4de4fbc0e5cb58001bc2dcb7b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 29 Feb 2024 01:30:06 +0000 Subject: [PATCH] Bug 33478: Consider TranslateNotices when saving notice styles This patch ensures saving styles per notice still works as expected when the TranslateNotices system preference is enabled. To test, enable the TranslateNotices system preference and attempt to save different CSS for each installed language for one notice. Confirm the correct CSS is saved for the correct language. Confirm the CSS selector helpers are inserted into the textarea as expected. Confirm the 'Apply format settings to all notices for this language' setting works, as in CSS is saved for all relevant language notices. Signed-off-by: Lucas Gass Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../prog/en/modules/tools/letter.tt | 33 ++++++++++--------- koha-tmpl/intranet-tmpl/prog/js/letter.js | 4 +-- tools/letter.pl | 14 ++++---- 3 files changed, 27 insertions(+), 24 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 107bc47220..47606c98f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -680,17 +680,17 @@
  1. - Headings - Tables - All text + Headings + Tables + All text
  2. -
  3. - - +
  4. + +
  5. -
  6. - - +
  7. + + Existing format settings will be overwritten.
@@ -719,23 +719,26 @@ var new_branchcode = '[% new_branchcode | html %]'; var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %]; $(document).ready(function(){ - $("#headings").click(function(){ - $("#style").val(function(i, text) { + $(".headings").click(function(){ + var lang = $(this).data('lang'); + $("#style_"+lang).val(function(i, text) { return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' + '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6 {\n' + '// insert CSS here\n' + '}'; }); }); - $("#tables").click(function(){ - $("#style").val(function(i, text) { + $(".tables").click(function(){ + var lang = $(this).data('lang'); + $("#style_"+lang).val(function(i, text) { return text + '\nbody, table, th, td, th:last-child, td:last-child {\n' + '// insert CSS here\n' + '}'; }); }); - $("#text").click(function(){ - $("#style").val(function(i, text) { + $(".text").click(function(){ + var lang = $(this).data('lang'); + $("#style_"+lang).val(function(i, text) { return text + 'pre, #slip, #slip h1, #slip h2, #slip h3, #slip h4, #slip h5, #slip h6,\n' + '#receipt, #receipt h1, #receipt h2, #receipt h3, #receipt h4, #receipt h5, #receipt h6,\n' + 'table, th, td, th:last-child, td:last-child {\n' + diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js index 5ea32df655..44524c0452 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/letter.js +++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js @@ -49,7 +49,7 @@ function confirmOverwrite( new_lettercode, new_branchcode ){ } function confirmFormatOverwrite( event ) { - if ( confirm(__("Existing format settings for all notices will be overwritten by these format settings.")) ) { + if ( confirm(__("Existing format settings for all notices of the same language will be overwritten by these format settings.")) ) { return true; } else { return false; @@ -94,7 +94,7 @@ $(document).ready(function() { }); $("#submit_form").on("click",function(e){ - if ( $("#format_all").is(":checked") ){ + if ( $(".format_all").is(":checked") ){ if ( confirmFormatOverwrite(e) ) { $("#add_notice").submit(); } else { diff --git a/tools/letter.pl b/tools/letter.pl index 430bc2e32e..dcd95fa613 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -307,18 +307,18 @@ sub add_validate { my $oldmodule = $input->param('oldmodule'); my $code = $input->param('code'); my $name = $input->param('name'); - my $style = $input->param('style'); - my $format_all = $input->param('format_all'); my @mtt = $input->multi_param('message_transport_type'); my @title = $input->multi_param('title'); my @content = $input->multi_param('content'); my @lang = $input->multi_param('lang'); for my $mtt ( @mtt ) { - my $lang = shift @lang; - if ( $format_all ) { - my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list; - foreach my $letter ( @letters ) { - $letter->set({ style => $style })->store; + my $lang = shift @lang; + my $style = $input->param("style_$lang"); + my $format_all = $input->param("format_all_$lang"); + if ($format_all) { + my @letters = Koha::Notice::Templates->search( { lang => $lang } )->as_list; + foreach my $letter (@letters) { + $letter->set( { style => $style } )->store; } } my $is_html = $input->param("is_html_$mtt\_$lang"); -- 2.39.5