From 9f6f1aaed5716660c9ffd10dd5897e5383cf87bb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 29 Nov 2012 16:27:27 +0100 Subject: [PATCH] Bug 9167: Standardize the sort field copyrightdate for lists Content-Type: text/plain; charset="utf-8" How to reproduce the issue: Create a list at the OPAC and select the sort field 'year'. Go to the list management page at the intranet: the sort field "copyrightdate" is not selected by default. How to test this patch: Check the issue is not still present with this patch. Create several lists at the OPAC with different sort field. Check results are consistent on both interfaces. Check the selected sort field is selected on the edit page. Check there is no regression. What this patch does: - change the way to send the selected sort field to the templates - remove the select tests on the new list page (useless) - the copyrightdate sortfield is named "copyrightdate" everywhere - update your database : set virtualshelves.sortfield = 'copyrightdate' if virtualshelves.sortfield = 'year' http://bugs.koha-community.org/show_bug.cgi?id=8032 Signed-off-by: Marcel de Rooy Works as advertised. Improves code. --- C4/VirtualShelves/Page.pm | 27 ++----------------- installer/data/mysql/updatedatabase.pl | 9 ++++++ .../prog/en/modules/virtualshelves/shelves.tt | 28 ++++++++++---------- .../opac-tmpl/prog/en/modules/opac-shelves.tt | 16 +++++----- 4 files changed, 34 insertions(+), 46 deletions(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index bf53563..6a4d431 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -214,7 +214,6 @@ sub shelfpage { my $member = GetMember( 'borrowernumber' => $owner ); my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : ''; $edit = 1; - $sortfield='' unless $sortfield; $template->param( edit => 1, display => $displaymode, @@ -224,7 +223,7 @@ sub shelfpage { ownername => $ownername, "category$category" => 1, category => $category, - "sort_$sortfield" => 1, + sortfield => $sortfield, allow_add => $allow_add, allow_delete_own => $allow_delete_own, allow_delete_other => $allow_delete_other, @@ -248,17 +247,9 @@ sub shelfpage { #check that the user can view the shelf if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) { my $items; - my $authorsort; - my $yearsort; my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); - if ( $sortfield eq 'author' ) { - $authorsort = 'author'; - } - if ( $sortfield eq 'year' ) { - $yearsort = 'year'; - } - ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield eq 'year' ? 'copyrightdate' : $sortfield ); + ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield ); for my $this_item (@$items) { my $biblionumber = $this_item->{'biblionumber'}; my $record = GetMarcBiblio($biblionumber); @@ -302,9 +293,7 @@ sub shelfpage { shelfname => $shelfname, shelfnumber => $shelfnumber, viewshelf => $shelfnumber, - authorsort => $authorsort, - yearsort => $yearsort, - itemcallnumbersort => $sortfield eq 'itemcallnumber', + sortfield => $sortfield, manageshelf => $manageshelf, allowremovingitems => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'delete'), allowaddingitem => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add'), @@ -413,16 +402,6 @@ sub shelfpage { my $category = $shelflist->{$element}->{'category'}; my $owner = $shelflist->{$element}->{'owner'}||0; my $canmanage = ShelfPossibleAction( $loggedinuser, $element, 'manage' ); - my $sortfield = $shelflist->{$element}->{'sortfield'}; - if ( $sortfield ){ - if ( $sortfield eq 'author' ) { - $shelflist->{$element}->{"authorsort"} = 'author'; - } elsif ( $sortfield eq 'year' ) { - $shelflist->{$element}->{"yearsort"} = 'year'; - } elsif ( $sortfield eq 'itemcallnumber' ) { - $shelflist->{$element}->{"itemcallnumbersort"} = 'itemcallnumber'; - } - } $shelflist->{$element}->{"viewcategory$category"} = 1; $shelflist->{$element}->{manageshelf} = $canmanage; if($canmanage || ($loggedinuser && $owner==$loggedinuser)) { diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6908704..6080ff2 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6125,6 +6125,15 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(q{ + UPDATE virtualshelves SET sortfield="copyrightdate" where sortfield="year"; + }); + print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 20ae8ee..81fe513 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -298,15 +298,15 @@ function placeHold () {
  1. Owner: [% loggedinusername %]
  2. -
  3. -
  4. +
  5. +
  6. -
  7. @@ -324,10 +324,10 @@ function placeHold () {
  8. [% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]
  9. - [% IF ( sort_title ) %][% ELSE %][% END %] - [% IF ( sort_author ) %][% ELSE %][% END %] - [% IF ( sort_year ) %][% ELSE %][% END %] - [% IF ( sort_itemcallnumber ) %][% ELSE %][% END %] + [% IF ( sortfield == "title" ) %][% ELSE %][% END %] + [% IF ( sortfield == "author" ) %][% ELSE %][% END %] + [% IF ( sortfield == "copyrightdate" ) %][% ELSE %][% END %] + [% IF ( sortfield == "itemcallnumber" ) %][% ELSE %][% END %]
  10. @@ -675,10 +675,10 @@ $(function() {
  11. -- 1.7.7.6