LP#1526546 Sort copies by part label in holdings maint.
authorRemington Steed <rjs7@calvin.edu>
Wed, 16 Dec 2015 20:46:17 +0000 (15:46 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 24 Feb 2016 15:33:39 +0000 (10:33 -0500)
This commit improves the sorting of copies on the Holdings Maintenance
screen in the XUL-based staff client. The previous code sorted the
copies by their barcodes after retrieval. This commit moves the sorting
logic into the search call and adds logic to first sort by the part
label sort key.

Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm

index 9c357d6..5267ddd 100644 (file)
@@ -680,11 +680,25 @@ sub _build_volume_list {
 
         my $copies = $e->search_asset_copy([
             { call_number => $volume->id , deleted => 'f' },
-            { flesh => 1, flesh_fields => { acp => ['stat_cat_entries','parts'] } }
+            {
+                join => {
+                    acpm => {
+                        type => 'left',
+                        join => {
+                            bmp => { type => 'left' }
+                        }
+                    }
+                },
+                flesh => 1,
+                flesh_fields => { acp => ['stat_cat_entries','parts'] },
+                order_by => [
+                    {'class' => 'bmp', 'field' => 'label_sortkey', 'transform' => 'oils_text_as_bytea'},
+                    {'class' => 'bmp', 'field' => 'label', 'transform' => 'oils_text_as_bytea'},
+                    {'class' => 'acp', 'field' => 'barcode'}
+                ]
+            }
         ]);
 
-        $copies = [ sort { $a->barcode cmp $b->barcode } @$copies  ];
-
         for my $c (@$copies) {
             if( $c->status == OILS_COPY_STATUS_CHECKED_OUT ) {
                 $c->circulations(