From 7b3a84c7bd293c876995392815ea0c27299a8284 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 2 May 2023 16:26:45 +0200 Subject: [PATCH] Bug 33335: Use To.json to serialize Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 706cd01ba264ded1f0b237c74f90e511acf2de81) Signed-off-by: Matt Blenkinsop (cherry picked from commit 04ce17dde59e4d5994bbe7547465e9b9afbd6e4e) Signed-off-by: Lucas Gass --- admin/marc-overlay-rules.pl | 10 ++++++---- .../prog/en/modules/admin/marc-overlay-rules.tt | 11 +++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/admin/marc-overlay-rules.pl b/admin/marc-overlay-rules.pl index 05a5bbe581..b3e0a86f8d 100755 --- a/admin/marc-overlay-rules.pl +++ b/admin/marc-overlay-rules.pl @@ -132,11 +132,13 @@ elsif ($op eq 'doedit' || $op eq 'add') { } } -my $categorycodes = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']}); +my $categories = Koha::Patron::Categories->search_with_library_limits( {}, + { order_by => ['description'] } )->unblessed; + $template->param( - rules => $rules, - categorycodes => $categorycodes, - messages => $errors + rules => $rules, + categories => $categories, + messages => $errors ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt index ea588a743d..e3f2db90e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE To %] [% USE Asset %] [% SET footerjs = 1 %] [% USE Koha %] @@ -453,11 +454,9 @@ } }); - var $category = {}; - - [% FOR categorycode IN categorycodes %] - $category["[% categorycode.categorycode %]"] = "[% categorycode.description | html %]"; - [% END %] + var categories = [% To.json( categories ) | $raw %]; + categories.unshift({ categorycode: '*', description: '*'}); + categories = categories.reduce( ( a,c ) => ( { ...a, [c.categorycode]: c.description } ), {} ); var module_filter_options = { source: { @@ -470,7 +469,7 @@ import_lexile: _("import_lexile.pl") }, - categorycode: $category + categorycode: categories, }; //Kind of hack: Replace filter value with label when one exist -- 2.39.5