Bug 33335: Use To.json to serialize

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 706cd01ba2)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-05-02 16:26:45 +02:00 committed by Matt Blenkinsop
parent e528bb87c7
commit 04ce17dde5
2 changed files with 11 additions and 10 deletions

View file

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

View file

@ -1,4 +1,5 @@
[% USE raw %]
[% USE To %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% USE Koha %]
@ -454,11 +455,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: {
@ -471,7 +470,7 @@
import_lexile: _("import_lexile.pl")
},
categorycode: $category
categorycode: categories,
};
//Kind of hack: Replace filter value with label when one exist