From 4e2f26b151d9fe1072e7ceffaabc9a31b6d4dfdb Mon Sep 17 00:00:00 2001
From: Kyle M Hall
Date: Wed, 23 Jan 2013 09:05:20 -0500
Subject: [PATCH] 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
(cherry picked from commit 4b95ee62394d1e31dfda3fdb2d027fc67482c349)
Solved Conflicts:
C4/VirtualShelves/Page.pm
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
Signed-off-by: Bernardo Gonzalez Kriegel
(cherry picked from commit 4b95ee62394d1e31dfda3fdb2d027fc67482c349)
---
C4/VirtualShelves.pm | 4 +--
C4/VirtualShelves/Page.pm | 8 +++--
.../prog/en/modules/virtualshelves/shelves.tt | 24 +++++++++++--
.../opac-tmpl/prog/en/modules/opac-shelves.tt | 34 +++++++++++++++++++
4 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm
index 5682a1557e..9702ad9c00 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);
@@ -276,7 +276,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 190c585802..61a4565d28 100644
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -258,7 +258,9 @@ sub shelfpage {
if ( $sortfield eq 'year' ) {
$yearsort = 'year';
}
- ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield eq 'year' ? 'copyrightdate' : $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);
@@ -438,7 +440,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;
@@ -478,6 +480,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 fde2b1f949..8fad486e88 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
@@ -204,13 +204,33 @@ function placeHold () {
[% END %]
+ [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %]
[% pagination_bar %]
[% IF ( itemsloop ) %] | [% END %]
+
[% UNLESS ( item_level_itypes ) %]Item type | [% END %]
- Title |
- Author |
+
+ 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 added |
|
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 be61dbaa8c..5a700a9c7d 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 ) %] |
--
2.39.5