Sort copies on record detail page with copies belonging to "sort org unit" first
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 28 Jul 2011 20:37:19 +0000 (16:37 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 28 Jul 2011 20:40:03 +0000 (16:40 -0400)
"sort org unit" needs to eventually be an abstract concept that could
either refer to "orig_loc" or to "loc" or perhaps be skipped altogether,
depending on some future configuration.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm

index e5743bc..6097498 100644 (file)
@@ -259,7 +259,7 @@ sub get_orig_loc {
         return $orig_loc;
     }
 
-    return $self->cgi->cookie('orig_loc');
+    return $self->cgi->cookie(COOKIE_ORIG_LOC);
 }
 
 
index a1f6777..f3391dd 100644 (file)
@@ -78,6 +78,12 @@ sub mk_copy_query {
     my $copy_limit = shift;
     my $copy_offset = shift;
 
+    # XXX In the future, $sort_org should be understood to be an abstration
+    # that refers to something configurable, not necessariyl orig_loc.
+
+    my $sort_org = $self->ctx->{orig_loc} || $org ||
+        $self->ctx->{aou_tree}->()->id;
+
     my $query = {
         select => {
             acp => ['id', 'barcode', 'circ_lib', 'create_date', 'age_protect', 'holdable'],
@@ -133,6 +139,8 @@ sub mk_copy_query {
 
         # Order is: copies with circ_lib=org, followed by circ_lib name, followed by call_number label
         order_by => [
+            {class => 'acp', field => 'circ_lib', transform => 'numeric_eq',
+                params => [$sort_org], direction => 'desc'},
             {class => 'aou', field => 'name'}, 
             {class => 'acn', field => 'label'}
         ],