ff ui : fetch pending holds via flattener
authorBill Erickson <berick@esilibrary.com>
Mon, 4 Nov 2013 21:32:30 +0000 (16:32 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 4 Nov 2013 21:32:56 +0000 (16:32 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/fulfillment/t_pending.tt2
Open-ILS/web/js/ui/default/staff/fulfillment/app.js

index 535a52f..22f1b24 100644 (file)
@@ -37,6 +37,7 @@
         <th>[% l('Patron Name') %]</th>
         <th>[% l('Patron Barcode') %]</th>
         <th>[% l('Requesting Library') %]</th>
+        <th>[% l('Pickup Library') %]</th>
         <th>[% l('Targeted Copy') %]</th>
         <th>[% l('Copy Library') %]</th>
         <th>[% l('Title') %]</th>
         <td>{{item.id}}</td>
         <td>{{item.request_time | date}}</td>
         <td>{{item.expire_time | date}}</td>
-        <td>{{item.patron_name}}</td>
-        <td>{{item.patron_card}}</td>
+        <td>{{item.patron_given_name}} {{item.patron_family_name}}</td>
+        <td>{{item.patron_barcode}}</td>
         <td>{{item.request_lib}}</td>
+        <td>{{item.pickup_lib}}</td>
         <td><a 
-          href="./fulfillment/status/{{item.current_copy_enc}}">
-            {{item.current_copy}}
+          href="./fulfillment/status/{{item.copy_barcode_enc}}">
+            {{item.copy_barcode}}
           </a>
         </td>
-        <td>{{item.current_copy_lib}}</td>
+        <td>{{item.circ_lib}}</td>
         <td>{{item.title}}</td>
     </tbody>
   </table>
index 3358169..fed493f 100644 (file)
@@ -721,38 +721,8 @@ function ($scope,  $q,  $route,  $location,  egPCRUD,  orgSelector) {
 .controller('PendingRequestsCtrl',
         ['$scope','$q','$route','egNet','egAuth','egPCRUD','egOrg','orgSelector',
 function ($scope,  $q,  $route,  egNet,  egAuth,  egPCRUD,  egOrg,  orgSelector) {
-    var self = this;
-
-    this.displayOne = function(display, hold_blob) {
-        var hold = display.hold = hold_blob.hold;
-        display.request_time = hold.hold_request_time = hold.request_time();
-        display.expire_time = hold.expire_time();
-        display.patron_card = hold_blob.patron_barcode;
-        display.patron_name = display.hold_request_usr = 
-          (hold_blob.patron_first || '') + 
-            ' ' + (hold_blob.patron_last || '');
-        display.request_lib = display.hold_request_lib = 
-            egOrg.get(hold.request_lib()).shortname();
-        display.hold_pickup_lib = 
-            egOrg.get(hold.pickup_lib()).shortname();
-        display.title = hold_blob.mvr.title(); // MVR BOO
-        display.author = hold_blob.mvr.author(); // MVR BOO
-        if (hold_blob.copy) {
-            display.copy = hold_blob.copy;
-            display.current_copy = hold_blob.copy.barcode();
-            display.current_copy_lib = 
-                egOrg.get(hold_blob.copy.source_lib()).shortname();
-            display.current_copy_enc = encodeURIComponent(hold_blob.copy.barcode());
-            display.barcode = display.copy.barcode();
-            display.status = display.copy.status();
-            display.item_circ_lib = egOrg.get(display.copy.circ_lib()).shortname();
-        }
-        if (hold_blob.volume) {
-            display.call_number = hold_blob.volume.label();
-        }
-        if ($scope.orientation_lender) 
-            display.next_action = 'ill-home-capture';
-    };
+
+    $scope.itemList.sort = 'request_time';
 
     $scope.drawTable = function() {
         $scope.itemList.items = [];
@@ -785,35 +755,55 @@ function ($scope,  $q,  $route,  egNet,  egAuth,  egPCRUD,  egOrg,  orgSelector)
             }
         }
 
-        egPCRUD.search('ahr', query,
-            {   limit : $scope.itemList.limit, 
-                offset : $scope.itemList.offset,
-                order_by : {'ahr' : 'request_time, id'}
-            }, 
-            {atomic : true}
+        // circ_lib and request_lib are retrieved as IDs since 
+        // our query blob assumes they are IDs
+        var fields = {
+            id : {path : 'id'},
+            request_time : {path : 'request_time'},
+            expire_time : {path : 'expire_time'},
+            patron_barcode : {path : 'usr.card.barcode'},
+            patron_given_name : {path : 'usr.first_given_name'},
+            patron_family_name : {path : 'usr.family_name'},
+            request_lib : {path : 'request_lib'},
+            pickup_lib : {path : 'pickup_lib.shortname'},
+            title : {path : 'bib_rec.bib_record.simple_record.title'},
+            author : {path : 'bib_rec.bib_record.simple_record.author'},
+            copy_barcode : {path : 'current_copy.barcode'},
+            circ_lib : {path : 'current_copy.circ_lib'},
+            call_number : {path : 'current_copy.call_number.label'}
+        };
+        angular.forEach(fields, function(f) { f.display = true });
 
-        ).then(function(holds) {
+        egNet.request(
+            'open-ils.fielder',
+            'open-ils.fielder.flattened_search',
+            egAuth.token(), "ahr", fields,
+            query,
+            {   sort : [$scope.itemList.sort],
+                limit : $scope.itemList.limit,
+                offset : $scope.itemList.offset
+            }
+        ).then(
+            null, // success
+            null, // error
+            function(hold) { // notify handler
+                hold.index = $scope.itemList.count();
+
+                hold.request_lib = egOrg.get(hold.request_lib).shortname();
+                if (hold.circ_lib) {
+                    hold.circ_lib = egOrg.get(hold.circ_lib).shortname();
+                    hold.copy_barcode_enc = encodeURIComponent(hold.copy_barcode);
+                }
+
+                if ($scope.orientation_lender) 
+                    hold.next_action = 'ill-home-capture';
 
-            // fetch the extended hold details for each hold
-            // to pick up the title, etc.
-            angular.forEach(holds, function(hold) {
-                var display = {
-                    id : hold.id(),
-                    index : $scope.itemList.count()
-                };
                 // we don't use itemList.addItem(), 
-                // since it fetches data differently
-                $scope.itemList.items.push(display);
-                egNet.request(
-                    'open-ils.circ',
-                    'open-ils.circ.hold.details.retrieve', 
-                    egAuth.token(), hold.id()
-                ).then(function(hold_blob) {
-                    self.displayOne(display, hold_blob);
-                });
-            });
-        });
-    };
+                // since we're managing our own data fetching
+                $scope.itemList.items.push(hold);
+            }
+        );
+    }
 
 
     $scope.firstPage = function() {
@@ -822,12 +812,12 @@ function ($scope,  $q,  $route,  egNet,  egAuth,  egPCRUD,  egOrg,  orgSelector)
     };
 
     $scope.nextPage = function() {
-        $scope.itemList.offset += $scope.itemList.limit;
+        $scope.itemList.incrementPage();
         $scope.drawTable();
     };
 
     $scope.prevPage = function() {
-        $scope.itemList.offset -= $scope.itemList.limit;
+        $scope.itemList.decrementPage();
         $scope.drawTable();
     };