From f06a162b27ba3e0859ae18f74fadace3d6dbaae5 Mon Sep 17 00:00:00 2001
From: Jason Stephenson <jason@sigio.com>
Date: Wed, 16 Mar 2022 13:29:09 -0400
Subject: [PATCH] LP1965161: Sort Monograph Parts in Holds Metadata

When placing a hold in the Angular Staff Catalog, parts are not sorted
in the proper order.  This patch corrects the sort order.

To verify the bug:

 1. Find a record with parts in your catalog.
 2. Place a hold on a specific part using the Angular Staff Catalog.
 3. Notice that the entries int he parts drop down are likely not
    sorted in the correct order. (If they are you lucked out and
    should try again with a different record.)

To verify the fix after applying the patch and re-installing
Evergreen, repeat the above steps.  The parts should display in the
proper sort order by label.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index f5489369ed..a11d0abfe7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -5145,7 +5145,11 @@ sub hold_metadata {
 
             # Also fetch the available parts for bib-level holds.
             $meta->{parts} = $e->search_biblio_monograph_part(
-                {record => $bre->id, deleted => 'f'});
+                [
+                    {record => $bre->id, deleted => 'f'},
+                    {order_by => {bmp => 'label_sortkey'}}
+                ]
+            );
         }
 
         if ($meta->{metarecord}) {
-- 
2.11.0