From: Kyle Huckins <khuckins@catalyte.io>
Date: Thu, 17 May 2018 21:08:27 +0000 (+0000)
Subject: lp1749502 Holds Pull List Print Order
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=30bed84f700ad2d742b3b7881a6a0e35aef98201;p=evergreen%2Fjoelewis.git

lp1749502 Holds Pull List Print Order

- Ensure copy shelf location position is available for each hold on
holds shelf.
- Add _copy_location_position to hold_data while printing.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>

 Changes to be committed:
	modified:   Open-ILS/src/templates/staff/share/print_templates/t_hold_pull_list.tt2
	modified:   Open-ILS/web/js/ui/default/staff/circ/services/holds.js

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Josh Stompro <stompro@stompro.org>
Signed-off-by: John Amundson <jamundson@cwmars.org>
---

diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_hold_pull_list.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_hold_pull_list.tt2
index 47be206f7a..8be65d4416 100644
--- a/Open-ILS/src/templates/staff/share/print_templates/t_hold_pull_list.tt2
+++ b/Open-ILS/src/templates/staff/share/print_templates/t_hold_pull_list.tt2
@@ -29,7 +29,7 @@ Template for printing a table of holds to pull. Fields include:
     </tr>
   </thead>
   <tbody>
-    <tr ng-repeat="hold_data in holds">
+    <tr ng-repeat="hold_data in holds | orderBy : ['hold._copy_location_position', 'volume.label']">
       <td>{{hold_data.hold.hold_type}}</td>
       <td>{{hold_data.title}}</td>
       <td>{{hold_data.author}}</td>
diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/holds.js b/Open-ILS/web/js/ui/default/staff/circ/services/holds.js
index f76d92b014..0401ac20f6 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/services/holds.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/services/holds.js
@@ -490,7 +490,7 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
         // current_copy is not always fleshed in the API
         if (hold.current_copy() && typeof hold.current_copy() != 'object') {
             hold.current_copy(hold_data.copy);
-            
+
             // likewise, current_copy's status isn't fleshed in the API
             if(hold.current_copy().status() !== null &&
                typeof hold.current_copy().status() != 'object')
@@ -498,6 +498,25 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
                     ).then(function(c) { hold.current_copy().status(c) });
         }
 
+        // current_copy's shelving location position isn't always accessible
+        if (hold.current_copy().location()) {
+            console.debug('fetching hold copy location order');
+            var location_id;
+            if (typeof hold.current_copy().location() != 'object') {
+                location_id = hold.current_copy().location();
+            } else {
+                location_id = hold.current_copy().location().id();
+            }
+            egCore.pcrud.search(
+                'acplo',
+                {location: location_id, org: egCore.auth.user().ws_ou()},
+                null,
+                {atomic:true}
+            ).then(function(orders) {
+                hold_data.hold._copy_location_position = orders[0].position();
+            });
+        }
+
         if (volume) {
             //Call number affixes are not always fleshed in the API
             if (volume.prefix() && typeof volume.prefix() != 'object') {