Bug 9458 - Add sorting to lists - QA Followup
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 19 Feb 2013 13:42:11 +0000 (08:42 -0500)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 13 Mar 2013 13:06:19 +0000 (09:06 -0400)
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/VirtualShelves.pm
C4/VirtualShelves/Page.pm
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt

index f632416..37babc1 100644 (file)
@@ -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 ?, ? ";
index ab807da..3dfbe60 100644 (file)
@@ -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;
index e9f3994..c02e454 100644 (file)
@@ -204,7 +204,7 @@ function placeHold () {
      <span class="clearall"></span></p>
  [% END %]
        
- [% IF direction == 'asc' %][% direction = 'desc' %][% ELSE %][% direction = 'asc' %][% END %]
+ [% IF direction == 'asc' %][% SET new_direction = 'desc' %][% ELSE %][% SET new_direction = 'asc' %][% END %]
  <div class="pages">[% pagination_bar %]</div>
     <table>
             <tr>
@@ -212,34 +212,40 @@ function placeHold () {
 
                 [% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=title&direction=[% direction %]">Title</a>
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=title&direction=[% new_direction %]">Title</a>
                     [% IF sort == 'title' %]
                         [% IF direction == 'asc' %]
                             <img src="/intranet-tmpl/prog/img/asc.gif" />
                         [% ELSIF direction == 'desc' %]
                             <img src="/intranet-tmpl/prog/img/desc.gif" />
                         [% END %]
+                    [% ELSE %]
+                        <img src="/intranet-tmpl/prog/img/ascdesc.gif" />
                     [% END %]
                 </th>
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=author&direction=[% direction %]">Author</a>
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=author&direction=[% new_direction %]">Author</a>
                    [% IF sort == 'author' %]
                         [% IF direction == 'asc' %]
                             <img src="/intranet-tmpl/prog/img/asc.gif" />
                         [% ELSIF direction == 'desc' %]
                             <img src="/intranet-tmpl/prog/img/desc.gif" />
                         [% END %]
+                    [% ELSE %]
+                        <img src="/intranet-tmpl/prog/img/ascdesc.gif" />
                     [% END %]
                  </th>
                 <th>Date added</th>
                 <th>
-                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=itemcallnumber&direction=[% direction %]">Call number</a>
+                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=itemcallnumber&direction=[% new_direction %]">Call number</a>
                    [% IF sort == 'itemcallnumber' %]
                         [% IF direction == 'asc' %]
                             <img src="/intranet-tmpl/prog/img/asc.gif" />
                         [% ELSIF direction == 'desc' %]
                             <img src="/intranet-tmpl/prog/img/desc.gif" />
                         [% END %]
+                    [% ELSE %]
+                        <img src="/intranet-tmpl/prog/img/ascdesc.gif" />
                     [% END %]
                  </th>
                 <th>&nbsp;</th>
index 59bedc7..3ad295d 100644 (file)
@@ -317,8 +317,28 @@ $(document).ready(function() {
             <option value="itemcallnumber">Call number</option>
         [% END %]
 
-        <input type="submit" id="sort-submit" value="Resort list" />
+        [% IF sort == 'copyrightdate' %]
+            <option value="copyrightdate" selected="selected">Copyright date</option>
+        [% ELSE %]
+            <option value="copyrightdate">Copyright date</option>
+        [% END %]
+    </select>
+
+    <select name="direction" onchange="$('#sorting-form').submit()">
+        [% IF direction == 'asc' %]
+            <option value="asc" selected="selected">Ascending</option>
+        [% ELSE %]
+            <option value="asc">Ascending</option>
+        [% END %]
+
+        [% IF direction == 'desc' %]
+            <option value="desc" selected="selected">Descending</option>
+        [% ELSE %]
+            <option value="desc">Descending</option>
+        [% END %]
     </select>
+
+    <input type="submit" id="sort-submit" value="Resort list" />
 </form>
 
                 [% IF ( manageshelf ) %] <span class="sep">|</span> <form method="get" action="opac-shelves.pl"><input type="hidden" name="op" value="modif" />