Bug 33335: (QA follow-up) Polishing and comments

Just send the codes and descriptions only to client.
Adding a few comments to the reduce construction.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 020bc275b0)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Marcel de Rooy 2023-05-12 08:33:32 +00:00 committed by Matt Blenkinsop
parent 04ce17dde5
commit 7eabf447d1
2 changed files with 3 additions and 1 deletions

View file

@ -133,7 +133,7 @@ elsif ($op eq 'doedit' || $op eq 'add') {
}
my $categories = Koha::Patron::Categories->search_with_library_limits( {},
{ order_by => ['description'] } )->unblessed;
{ order_by => ['description'], columns => [ 'categorycode', 'description' ] } )->unblessed;
$template->param(
rules => $rules,

View file

@ -456,6 +456,8 @@
});
var categories = [% To.json( categories ) | $raw %];
// Add * => * to this array of objects, and *reduce* it to one object
// Note: This allows displaying a sorted list of categories later, but we still depend on an object!
categories.unshift({ categorycode: '*', description: '*'});
categories = categories.reduce( ( a,c ) => ( { ...a, [c.categorycode]: c.description } ), {} );