Bugzilla – Attachment 130069 Details for
Bug 29695
Centralize columns' descriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29695: Make "modalselect" syspref's values translatable
Bug-29695-Make-modalselect-sysprefs-values-transla.patch (text/plain), 5.12 KB, created by
Jonathan Druart
on 2022-02-02 09:48:00 UTC
(
hide
)
Description:
Bug 29695: Make "modalselect" syspref's values translatable
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-02 09:48:00 UTC
Size:
5.12 KB
patch
obsolete
>From 47c5624b8a54caf54fa27f6544787eaea9184ac2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Dec 2021 17:00:50 +0100 >Subject: [PATCH] Bug 29695: Make "modalselect" syspref's values translatable > >We are using json files to retrieve the list of the DB columns. We can >reuse what we have done in the previous patch and display translated >strings. > >Test plan: >Search for "unwanted" in the sysprefs >--- > admin/preferences.pl | 6 +- > .../prog/en/modules/admin/preferences.tt | 1 + > .../prog/js/pages/preferences.js | 60 +++++++++---------- > 3 files changed, 35 insertions(+), 32 deletions(-) > >diff --git a/admin/preferences.pl b/admin/preferences.pl >index f405419999a..e95aebc0f27 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -28,6 +28,7 @@ use C4::ClassSource qw( GetClassSources GetClassSource ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Templates; > use Koha::Acquisition::Currencies; >+use Koha::Database::Columns; > use IO::File; > use YAML::XS; > use Encode; >@@ -401,6 +402,9 @@ if ( $tab ) { > ); > } > >-$template->param( TABS => \@TABS ); >+$template->param( >+ TABS => \@TABS, >+ db_columns => Koha::Database::Columns->columns, >+); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >index 6842a59b136..e5e69bb521b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >@@ -282,6 +282,7 @@ > // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw > var to_highlight = "[% To.json( searchfield ) | $raw %]"; > var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %]; >+ var db_columns = [% To.json( db_columns ) | $raw %]; > </script> > [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] > [% Asset.js("js/ajax.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index b60fbe57c2a..fb63d4b3978 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >@@ -231,38 +231,36 @@ $( document ).ready( function () { > var pref_value = this.value; > var prefs = pref_value.split("|"); > >- >- >- $.getJSON( themelang + "/modules/admin/preferences/" + datasource + ".json", function( data ){ >- var items = []; >- var checked = ""; >- var readonly = ""; >- var disabled = ""; >- var style = ""; >- $.each( data, function( key, val ){ >- if( prefs.indexOf( val ) >= 0 ){ >- checked = ' checked="checked" '; >- } else { >- checked = ""; >- } >- if( required.indexOf( val ) >= 0 ){ >- style = "required"; >- checked = ' checked="checked" '; >- } else if( exclusions.indexOf( val ) >= 0 ){ >- style = "disabled"; >- disabled = ' disabled="disabled" '; >- checked = ""; >- } else { >- style = ""; >- disabled = ""; >- } >- items.push('<label class="' + style +'"><input class="dbcolumn_selection" type="checkbox" id="' + key + '"' + checked + disabled + ' name="pref" value="' + key + '" /> ' + val + ' (' + key + ')</label>'); >- }); >- $("<div/>", { >- "class": "columns-2", >- html: items.join("") >- }).appendTo("#prefModalForm"); >+ let data = db_columns[datasource]; >+ var items = []; >+ var checked = ""; >+ var readonly = ""; >+ var disabled = ""; >+ var style = ""; >+ $.each( Object.keys(data).sort(), function( i, key ){ >+ if( prefs.indexOf( key ) >= 0 ){ >+ checked = ' checked="checked" '; >+ } else { >+ checked = ""; >+ } >+ if( required.indexOf( key ) >= 0 ){ >+ style = "required"; >+ checked = ' checked="checked" '; >+ } else if( exclusions.indexOf( key ) >= 0 ){ >+ style = "disabled"; >+ disabled = ' disabled="disabled" '; >+ checked = ""; >+ } else { >+ style = ""; >+ disabled = ""; >+ } >+ items.push('<label class="' + style +'"><input class="dbcolumn_selection" type="checkbox" id="' + key + '"' + checked + disabled + ' name="pref" value="' + key + '" /> ' + data[key]+ ' (' + key + ')</label>'); > }); >+ $("<div/>", { >+ "class": "columns-2", >+ html: items.join("") >+ }).appendTo("#prefModalForm"); >+ > $("#saveModalPrefs").data("target", this.id ); > $("#prefModalLabel").text( pref_name ); > $("#prefModal").modal("show"); >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29695
:
128522
|
128523
|
128524
|
128525
|
128526
|
128527
|
128528
|
128529
|
128559
|
128560
|
128561
|
128562
|
128563
|
128564
|
128565
|
130065
|
130066
|
130067
|
130068
|
130069
|
130070
|
130071
|
130107
|
130108
|
130109
|
130110
|
130111
|
130112
|
130113
|
131918
|
131919
|
131920
|
131921
|
131922
|
131923
|
131924
|
131925