Lp#1712854 - fix issue with pickup lib change
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Fri, 15 Dec 2017 15:39:29 +0000 (10:39 -0500)
committerCesar Velez <cesar.velez@equinoxinitiative.org>
Fri, 15 Dec 2017 15:39:29 +0000 (10:39 -0500)
Since we are now pre-loading/caching all holds in order to enable
clientsort, we need to purge that cache when ou is changed.

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

Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 8c94f5b..20bd078 100644 (file)
@@ -20,7 +20,7 @@ angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','ngLocationUpdate','egC
 .config(function($routeProvider, $locationProvider, $compileProvider) {
     $locationProvider.html5Mode(true);
     $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|blob):/); // grid export
-       
+
     var resolver = {delay : ['egCore','egStartup','egUser', function(egCore, egStartup, egUser) {
         egCore.env.classLoaders.aous = function() {
             return egCore.org.settings([
@@ -1647,7 +1647,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     function fetchHolds() {
         return egHolds.fetch_holds(hold_ids).then(null, null,
             function(hold_data) {
-               holds.push(hold_data);
+                holds.push(hold_data);
                 return hold_data;
             }
         );
@@ -1657,10 +1657,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         if ($scope.record_tab != 'holds') return $q.when();
         var deferred = $q.defer();
 
-       // see if we can use cached results
-       if (holds[offset]){
-           return provider.arrayNotifier(holds, offset, count);
-       }
+        // 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});
 
@@ -1714,8 +1714,11 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     // refresh the list of record holds when the pickup lib is changed.
     $scope.pickup_ou = egCore.org.get(egCore.auth.user().ws_ou());
     $scope.pickup_ou_changed = function(org) {
+        if($scope.pickup_ou.id() != org.id()){
         $scope.pickup_ou = org;
-        provider.refresh();
+            holds = []; // cached hold data is stale due to ou change, clear it
+        }
+        provider.refresh(false);
     }
 
     $scope.print_holds = function() {