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 <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Aleisha Amohia 2024-02-29 01:30:06 +00:00 committed by Katrin Fischer
parent c6cb14b3c6
commit 225a6747f0
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
3 changed files with 27 additions and 24 deletions

View File

@ -680,17 +680,17 @@
<ol>
<li id="css-helpers">
<label>Insert selectors to apply styles to: </label>
<a class="css-helper" id="headings">Headings</a>
<a class="css-helper" id="tables">Tables</a>
<a class="css-helper" id="text">All text</a>
<a class="css-helper headings" data-lang="[% lang | html %]">Headings</a>
<a class="css-helper tables" data-lang="[% lang | html %]">Tables</a>
<a class="css-helper text" data-lang="[% lang | html %]">All text</a>
</li>
<li>
<label for="style">Style (CSS): </label>
<textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea>
<li class="style_notices_option">
<label for="style_[% lang | html %]">Style (CSS): </label>
<textarea id="style_[% lang | html %]" name="style_[% lang | html %]" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea>
</li>
<li>
<label for="format_all">Apply format settings to all notices:</label>
<input type="checkbox" name="format_all" id="format_all" value="1" />
<li class="format_all_notices_option">
<label for="format_all_[% lang | html %]">Apply format settings to all notices[% IF Koha.Preference('TranslateNotices') %] for this language[% END %]:</label>
<input type="checkbox" name="format_all_[% lang | html %]" id="format_all_[% lang | html %]" class="format_all" value="1" />
<span class="hint">Existing format settings will be overwritten.</span>
</li>
</ol>
@ -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' +

View File

@ -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 {

View File

@ -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");