LP#1712854 - enable grid data caching for record holds view
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Tue, 31 Oct 2017 18:53:09 +0000 (14:53 -0400)
committerCesar Velez <cesar.velez@equinoxinitiative.org>
Wed, 24 Jan 2018 16:19:48 +0000 (11:19 -0500)
Caching was explicitly disabled for record holds view grid,
needed to be enabled for clientsort to work. IIRC there was
 a bug where the holds were duplicating but that's no longer
an issue.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Open-ILS/src/templates/staff/cat/catalog/t_holds.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 00b686c..7285895 100644 (file)
@@ -64,8 +64,8 @@
       </a>
     </eg-grid-field>
 
-    <eg-grid-field label="[% l('Patron Barcode') %]">{{item.patron_barcode}}</eg-grid-field>
-    <eg-grid-field label="[% l('Patron alias') %]">{{item.patron_alias}}</eg-grid-field>
+    <eg-grid-field label="[% l('Patron Barcode') %]" path='patron_barcode'></eg-grid-field>
+    <eg-grid-field label="[% l('Patron alias') %]" path='patron_alias'></eg-grid-field>
     <eg-grid-field label="[% l('Request Date') %]" path='hold.request_time' datatype="timestamp"></eg-grid-field>
     <eg-grid-field label="[% l('Capture Date') %]" path='hold.capture_time' datatype="timestamp"></eg-grid-field>
     <eg-grid-field label="[% l('Available Date') %]" path='hold.shelf_time' datatype="timestamp"></eg-grid-field>
index 63b9c04..cf4da3c 100644 (file)
@@ -1641,12 +1641,15 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     $scope.grid_actions.refresh = function () { provider.refresh() };
     $scope.hold_grid_controls = {};
 
-    var hold_ids = []; // current list of holds
+    var holds = []; // actual hold objs for caching
+    var hold_ids = []; // current list of hold ids
+
     function fetchHolds(offset, count) {
         var ids = hold_ids.slice(offset, offset + count);
 
         return egHolds.fetch_holds(ids).then(null, null,
-            function(hold_data) { 
+            function(hold_data) {
+               holds.push(hold_data);
                 return hold_data;
             }
         );
@@ -1655,8 +1658,11 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     provider.get = function(offset, count) {
         if ($scope.record_tab != 'holds') return $q.when();
         var deferred = $q.defer();
-        hold_ids = []; // no caching ATM
 
+       // see if we can use cached results
+       if (holds[offset]){
+           return provider.arrayNotifier(holds, offset, count);
+       }
         // open a determinate progress dialog, max value set below.
         egProgressDialog.open({max : 1, value : 0});