Bug 13908 - Checkouts table sorting is not honoring default sort preferences
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 25 Mar 2015 15:33:48 +0000 (11:33 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 8 Apr 2015 13:09:04 +0000 (10:09 -0300)
The checkouts table no longer honors the system preferences
todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.

This causes much frustration for librarians who prefer a different sort
order. In particular, many librarians prefer to see the oldest previous
issues at the top of the list so those overdue items are visible "above
the fold".

Test Plan:
1) Apply this patch
2) Find a patron with many previous checkouts due on different days
3) Try all 4 combinations of todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder
4) Note they all sort correctly

Signed-off-by: Sean McGarvey <seanm@pascolibraries.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js
svc/checkouts

index a7f86d0..78d2cb7 100644 (file)
@@ -174,11 +174,7 @@ $(document).ready(function() {
             "aoColumns": [
                 {
                     "mDataProp": function( oObj ) {
-                        if ( oObj.issued_today ) {
-                            return "1" + oObj.timestamp;
-                        } else {
-                            return "0" + oObj.date_due;
-                        }
+                        return oObj.sort_order;
                     }
                 },
                 {
@@ -423,7 +419,7 @@ $(document).ready(function() {
             {
                 iGroupingColumnIndex: 1,
                 iGroupingOrderByColumnIndex: 0,
-                sGroupingColumnSortDirection: "desc"
+                sGroupingColumnSortDirection: "asc"
             }
         );
 
index cfd42dc..af373aa 100755 (executable)
@@ -207,13 +207,21 @@ while ( my $c = $sth->fetchrow_hashref() ) {
     }
 }
 
+
+@checkouts_today = sort { $a->{timstamp} cmp $b->{timestamp} } @checkouts_today;
 @checkouts_today = reverse(@checkouts_today)
-  if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
+  unless ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
+
+@checkouts_previous = sort { $a->{date_due} cmp $b->{date_due} } @checkouts_previous;
 @checkouts_previous = reverse(@checkouts_previous)
   if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' );
 
 my @checkouts = ( @checkouts_today, @checkouts_previous );
 
+my $i = 1;
+map { $_->{sort_order} = $i++ } @checkouts;
+
+
 my $data;
 $data->{'iTotalRecords'}        = scalar @checkouts;
 $data->{'iTotalDisplayRecords'} = scalar @checkouts;