From 05a8fa8850d9ed56d0f513ce85e6c8b71fa1eca7 Mon Sep 17 00:00:00 2001 From: Chloe Zermatten Date: Mon, 16 Dec 2024 11:04:59 +0000 Subject: [PATCH] Bug 38712: order My Lists options alphabetically In the top header navigation menu, sets the order of the 'My Lists' dropdown to be alphabetical. Note: this patch was updated to also handle cases where $params->{search_attributes} is not defined, and also to ensure that it also applies to the list of public lists show to users who are not logged in. Test plan: - on the Koha OPAC, navigate to /cgi-bin/koha/opac-shelves.pl - create a few public and private lists - open the 'My List' dropdown in the top navigation menu - notice that the lists appear in the order they were created - apply the patch - open the 'My List' dropdown in the top navigation - notice that the lists are now sorted alphabetically --- C4/Auth.pm | 4 ++++ Koha/Illbackends/FreeForm | 1 + Koha/Virtualshelves.pm | 14 +++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 160000 Koha/Illbackends/FreeForm diff --git a/C4/Auth.pm b/C4/Auth.pm index 0ee06104a4..c7f645815c 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -333,11 +333,13 @@ sub get_template_and_user { { borrowernumber => $borrowernumber, public => 0, + search_attributes => {order_by => { -asc => 'shelfname' }}, } ); my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( { public => 1, + search_attributes => {order_by => { -asc => 'shelfname' }}, } ); $template->param( @@ -420,6 +422,7 @@ sub get_template_and_user { my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( { public => 1, + search_attributes => {order_by => { -asc => 'shelfname' }}, } ); $template->param( @@ -1481,6 +1484,7 @@ sub checkauth { my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( { public => 1, + search_attributes => {order_by => { -asc => 'shelfname' }}, } ); $template->param( diff --git a/Koha/Illbackends/FreeForm b/Koha/Illbackends/FreeForm new file mode 160000 index 0000000000..66a6582897 --- /dev/null +++ b/Koha/Illbackends/FreeForm @@ -0,0 +1 @@ +Subproject commit 66a6582897c2fa5f7a38e115fbd5f3fc4658f55c diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index 58653130a4..b6c43b692b 100644 --- a/Koha/Virtualshelves.pm +++ b/Koha/Virtualshelves.pm @@ -191,16 +191,20 @@ sub get_some_shelves { }; } + my $default_search_attributes = { + join => [ 'virtualshelfshares' ], + distinct => 'shelfnumber', + order_by => { -desc => 'lastmodified' }, + }; + + my %search_attributes = defined($params->{search_attributes}) ? (%{$default_search_attributes}, %{$params->{search_attributes}}) : %{$default_search_attributes}; + $self->search( { public => $public, ( @conditions ? ( -and => \@conditions ) : () ), }, - { - join => [ 'virtualshelfshares' ], - distinct => 'shelfnumber', - order_by => { -desc => 'lastmodified' }, - } + \%search_attributes ); } -- 2.39.2