From e37cdc44e94f6b74224abaeb7c0cd1810fd1e8ab Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 17 Jan 2025 09:51:17 -0500 Subject: [PATCH] Bug 36188: (QA follow-up) Tidy code Signed-off-by: Kyle M Hall --- opac/opac-shelves.pl | 11 +++++++---- virtualshelves/shelves.pl | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 7577c963679..87037c0b966 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -148,7 +148,8 @@ if ( $op eq 'add_form' ) { if ( $shelf ) { $op = $referer; my $sortfield = $query->param('sortfield'); - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); + $sortfield = 'title' + unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); if ( $shelf->can_be_managed( $loggedinuser ) ) { $shelf->shelfname( scalar $query->param('shelfname') ); $shelf->sortfield( $sortfield ); @@ -315,12 +316,14 @@ if ( $op eq 'view' ) { # By default order descending if sorting by dateaccessioned if ( $query->param('direction') ) { - $direction = $query->param('direction'); + $direction = $query->param('direction'); } elsif ( $sortfield eq 'dateaccessioned' and !$query->param('direction') ) { - $direction = 'desc'; + $direction = 'desc'; } $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' ); - $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); + $sortfield = 'title' + if !$sortfield + or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); my $rows; if ( $query->param('print') or $query->param('rss') ) { diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index ae3f58dde3b..90dc8bc8678 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -120,7 +120,8 @@ if ( $op eq 'add_form' ) { if ( $shelf ) { $op = $referer; my $sortfield = $query->param('sortfield'); - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); + $sortfield = 'title' + unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); if ( $shelf->can_be_managed( $loggedinuser ) ) { $shelf->shelfname( scalar $query->param('shelfname') ); $shelf->sortfield( $sortfield ); @@ -277,8 +278,13 @@ if ( $op eq 'view' ) { $shelf = Koha::Virtualshelves->find($shelfnumber); if ( $shelf ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { - my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting - $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); + my $sortfield = + $query->param('sortfield') + || $shelf->sortfield + || 'title'; # Passed in sorting overrides default sorting + $sortfield = 'title' + unless grep { $_ eq $sortfield } + qw( title author copyrightdate itemcallnumber dateadded dateaccessioned ); my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; -- 2.39.5 (Apple Git-154)