From 4b95ee62394d1e31dfda3fdb2d027fc67482c349 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 23 Jan 2013 09:05:20 -0500 Subject: [PATCH 1/5] Bug 9458 - Add sorting to lists Test Plan: 1) Apply patch 2) View list in staff interface, try sorting by title, then author 3) Repeat 2 with same list in OPAC Signed-off-by: Delaye Stephane Signed-off-by: Jonathan Druart Signed-off-by: Jared Camins-Esakov --- C4/VirtualShelves.pm | 4 +-- C4/VirtualShelves/Page.pm | 8 +++-- .../prog/en/modules/virtualshelves/shelves.tt | 35 +++++++++++++++++-- .../opac-tmpl/prog/en/modules/opac-shelves.tt | 34 ++++++++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 0bb4b56ec1..f63241604b 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -255,7 +255,7 @@ from C4::Circulation. =cut sub GetShelfContents { - my ($shelfnumber, $row_count, $offset, $sortfield) = @_; + my ($shelfnumber, $row_count, $offset, $sortfield, $sort_direction ) = @_; my $dbh=C4::Context->dbh(); my $sth1 = $dbh->prepare("SELECT count(*) FROM virtualshelfcontents WHERE shelfnumber = ?"); $sth1->execute($shelfnumber); @@ -277,7 +277,7 @@ sub GetShelfContents { my @params = ($shelfnumber); if($sortfield) { $query .= " ORDER BY " . $sortfield; - $query .= " DESC " if ($sortfield eq 'copyrightdate'); + $query .= " DESC " if ( ( $sortfield eq 'copyrightdate' ) || ( $sort_direction eq 'desc' ) ); } if($row_count){ $query .= " LIMIT ?, ? "; diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 586384d18b..ab807da6b5 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -249,7 +249,9 @@ sub shelfpage { my $items; my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); - ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield ); + $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting + my $direction = $query->param('direction'); + ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction ); for my $this_item (@$items) { my $biblionumber = $this_item->{'biblionumber'}; my $record = GetMarcBiblio($biblionumber); @@ -419,7 +421,7 @@ sub shelfpage { my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl"; my %qhash = (); - foreach (qw(display viewshelf sortfield)) { + foreach (qw(display viewshelf sortfield sort direction)) { $qhash{$_} = $query->param($_) if $query->param($_); } ( scalar keys %qhash ) and $url .= '?' . join '&', map { "$_=$qhash{$_}" } keys %qhash; @@ -459,6 +461,8 @@ sub shelfpage { barshelvesloop => $barshelves, pubshelves => $total->{pubtotal}, pubshelvesloop => $pubshelves, + sort => $query->param('sort'), + direction => $query->param('direction'), ); output_html_with_http_headers $query, $cookie, $template->output; 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 1eda7c94cc..e9f399468d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -204,15 +204,44 @@ function placeHold () {

[% END %] + [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %]
[% pagination_bar %]
[% IF ( itemsloop ) %][% END %] + [% UNLESS ( item_level_itypes ) %][% END %] - - + + - + [% FOREACH itemsloo IN itemsloop %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt index d6c1ed5234..59bedc7af4 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt @@ -188,6 +188,11 @@ $(function() { alert(alertString2); } } + +$(document).ready(function() { + $('#sort-submit').hide(); +}); + //]]> @@ -287,6 +292,35 @@ $(function() { Print list + + + + + + + + [% IF ( manageshelf ) %] | From bc9f606ca7025417f3f2fddd393983cc0beec0ba Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 19 Feb 2013 08:42:11 -0500 Subject: [PATCH 2/5] Bug 9458 - Add sorting to lists - QA Followup Signed-off-by: Jonathan Druart Signed-off-by: Jared Camins-Esakov --- C4/VirtualShelves.pm | 2 +- C4/VirtualShelves/Page.pm | 10 +++++---- .../prog/en/modules/virtualshelves/shelves.tt | 14 ++++++++---- .../opac-tmpl/prog/en/modules/opac-shelves.tt | 22 ++++++++++++++++++- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index f63241604b..37babc1c50 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -277,7 +277,7 @@ sub GetShelfContents { my @params = ($shelfnumber); if($sortfield) { $query .= " ORDER BY " . $sortfield; - $query .= " DESC " if ( ( $sortfield eq 'copyrightdate' ) || ( $sort_direction eq 'desc' ) ); + $query .= " DESC " if ( $sort_direction eq 'desc' ); } if($row_count){ $query .= " LIMIT ?, ? "; diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index ab807da6b5..3dfbe60694 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -249,8 +249,12 @@ sub shelfpage { my $items; my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); - $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting - my $direction = $query->param('direction'); + $sortfield = $query->param('sort') || $sortfield || 'title'; ## Passed in sorting overrides default sorting + my $direction = $query->param('direction') || 'asc'; + $template->param( + sort => $sortfield, + direction => $direction, + ); ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction ); for my $this_item (@$items) { my $biblionumber = $this_item->{'biblionumber'}; @@ -461,8 +465,6 @@ sub shelfpage { barshelvesloop => $barshelves, pubshelves => $total->{pubtotal}, pubshelvesloop => $pubshelves, - sort => $query->param('sort'), - direction => $query->param('direction'), ); output_html_with_http_headers $query, $cookie, $template->output; 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 e9f399468d..c02e454c6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -204,7 +204,7 @@ function placeHold () {

[% END %] - [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %] + [% IF direction == 'asc' %][% SET new_direction = 'desc' %][% ELSE %][% SET new_direction = 'asc' %][% END %]
[% pagination_bar %]
 Item typeTitleAuthor + Title + [% IF sort == 'title' %] + [% IF direction == 'asc' %] + + [% ELSIF direction == 'desc' %] + + [% END %] + [% END %] + + Author + [% IF sort == 'author' %] + [% IF direction == 'asc' %] + + [% ELSIF direction == 'desc' %] + + [% END %] + [% END %] + Date addedCall number + Call number + [% IF sort == 'itemcallnumber' %] + [% IF direction == 'asc' %] + + [% ELSIF direction == 'desc' %] + + [% END %] + [% END %] +  
@@ -212,34 +212,40 @@ function placeHold () { [% UNLESS ( item_level_itypes ) %][% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt index 59bedc7af4..3ad295d0b1 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt @@ -317,8 +317,28 @@ $(document).ready(function() { [% END %] - + [% IF sort == 'copyrightdate' %] + + [% ELSE %] + + [% END %] + + + + [% IF ( manageshelf ) %] | From be48d34b4f1407178e7f3cddf45721a96025f833 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 26 Feb 2013 10:34:20 -0500 Subject: [PATCH 3/5] Bug 9458 - Add sorting to lists - QA Followup 2 Signed-off-by: Jared Camins-Esakov --- C4/VirtualShelves.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 37babc1c50..254d732413 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -276,7 +276,7 @@ sub GetShelfContents { WHERE vc.shelfnumber=? "; my @params = ($shelfnumber); if($sortfield) { - $query .= " ORDER BY " . $sortfield; + $query .= " ORDER BY " . $dbh->quote_identifier( $sortfield ); $query .= " DESC " if ( $sort_direction eq 'desc' ); } if($row_count){ From 1ac83c05949582846171089f77eff220d61915d2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 5 Mar 2013 12:46:45 -0500 Subject: [PATCH 4/5] Bug 9458 - Add sorting to lists - QA Followup 3 Signed-off-by: Jared Camins-Esakov --- C4/VirtualShelves/Page.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index 3dfbe60694..f393cb1526 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -249,7 +249,7 @@ sub shelfpage { my $items; my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); - $sortfield = $query->param('sort') || $sortfield || 'title'; ## Passed in sorting overrides default sorting + $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting my $direction = $query->param('direction') || 'asc'; $template->param( sort => $sortfield, From f0c58df12e7bb7e9a42abf52cc113dcb85c8002f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 7 Mar 2013 13:30:27 -0500 Subject: [PATCH 5/5] Bug 9458 - Add sorting to lists - QA Followup 4 Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/virtualshelves/shelves.tt | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) 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 c02e454c6f..84fb29e0f3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -204,7 +204,13 @@ function placeHold () {

[% END %] - [% IF direction == 'asc' %][% SET new_direction = 'desc' %][% ELSE %][% SET new_direction = 'asc' %][% END %] + [% IF direction == 'asc' %] + [% SET new_direction = 'desc' %] + [% ELSE %] + [% SET direction = 'desc' %] + [% SET new_direction = 'asc' %] + [% END %] +
[% pagination_bar %]
Item type - Title + Title [% IF sort == 'title' %] [% IF direction == 'asc' %] [% ELSIF direction == 'desc' %] [% END %] + [% ELSE %] + [% END %] - Author + Author [% IF sort == 'author' %] [% IF direction == 'asc' %] [% ELSIF direction == 'desc' %] [% END %] + [% ELSE %] + [% END %] Date added - Call number + Call number [% IF sort == 'itemcallnumber' %] [% IF direction == 'asc' %] [% ELSIF direction == 'desc' %] [% END %] + [% ELSE %] + [% END %]  
@@ -212,41 +218,29 @@ function placeHold () { [% UNLESS ( item_level_itypes ) %][% END %]
Item type - Title + Title [% IF sort == 'title' %] - [% IF direction == 'asc' %] - - [% ELSIF direction == 'desc' %] - - [% END %] + [% ELSE %] [% END %] - Author + Author [% IF sort == 'author' %] - [% IF direction == 'asc' %] - - [% ELSIF direction == 'desc' %] - - [% END %] - [% ELSE %] - - [% END %] + + [% ELSE %] + + [% END %] Date added - Call number + Call number [% IF sort == 'itemcallnumber' %] - [% IF direction == 'asc' %] - - [% ELSIF direction == 'desc' %] - - [% END %] - [% ELSE %] - - [% END %] + + [% ELSE %] + + [% END %]