holds shelf. clear shelf
authorBill Erickson <berick@esilibrary.com>
Wed, 9 Jul 2014 15:46:22 +0000 (11:46 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 9 Jul 2014 15:46:22 +0000 (11:46 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/holds/index.tt2
Open-ILS/web/js/ui/default/staff/circ/holds/app.js

index 5bcac1c..b11ae2e 100644 (file)
@@ -17,6 +17,9 @@
 <script>
 angular.module('egCoreMod').run(['egStrings', function(s) {
   s.CLEAR_SHELF_ACTION_shelf = "[% l('Reshelve') %]";
+  s.CLEAR_SHELF_ACTION_hold = "[% l('Needed for Hold') %]";
+  s.CLEAR_SHELF_ACTION_transit = "[% l('Needs Transiting') %]";
+  s.CLEAR_SHELF_ACTION_pl_changed = "[% l('Wrong Shelf') %]";
 }])
 </script>
 [% END %]
index 09772b9..607febf 100644 (file)
@@ -190,9 +190,29 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
         egHolds.retarget(hold_ids).then(refresh_page);
     }
 
+
+    // udpate the in-grid hold with the clear-shelf cached response info.
+    function handle_clear_cache_resp(resp) {
+        console.debug('clear shelf said: ' + js2JSON(resp));
+        if (!angular.isArray(resp)) resp = [resp];
+        angular.forEach(resp, function(info) {
+            if (info.action) {
+                var grid_item = holds.filter(function(item) {
+                    return item.hold.id() == info.hold_details.id
+                })[0];
+
+                // there will be no grid item if the hold is off-page
+                if (grid_item) {
+                    grid_item.post_clear = 
+                        egCore.strings['CLEAR_SHELF_ACTION_' + info.action];
+                }
+            }
+        });
+    }
+
     $scope.clear_holds = function() {
         clearing = true;
-        $scope.clear_progress = { max : 0, value : 0 };
+        $scope.clear_progress = {max : 0, value : 0};
 
         // we want to see all processed holds, so (effectively) remove
         // the grid limit.
@@ -205,43 +225,29 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
             egCore.auth.token(), $scope.pickup_ou.id()
 
         // request responses from the clear shelf cache
-        ).then(function(resp) {
-            console.debug('clear holds cache key is ' + resp.cache_key);
-            return egCore.net.request(
-                'open-ils.circ',
-                'open-ils.circ.hold.clear_shelf.get_cache',
-                egCore.auth.token(), resp.cache_key
-            )
-
-        // with each clear-shelf response, update the progress meter,
-        // hide it when done.
-        }).then(
-            function() { 
+        ).then(
+            
+            // clear shelf done; fetch the cached results.
+            function(resp) {
                 clearing = false;
-            },
+                console.debug('clear holds cache key is ' + resp.cache_key);
+                egCore.net.request(
+                    'open-ils.circ',
+                    'open-ils.circ.hold.clear_shelf.get_cache',
+                    egCore.auth.token(), resp.cache_key
+                ).then(null, null, handle_clear_cache_resp);
+            }, 
+
             null,
+
+            // handle streamed clear_shelf progress updates
             function(resp) {
-                console.debug('clear shelf said: ' + js2JSON(resp));
-                if (!angular.isArray(resp)) resp = [resp];
-                angular.forEach(resp, function(info) {
-                    if (info.maximum) 
-                        $scope.clear_progress.max = info.maximum;
-                    if (info.progress)
-                        $scope.clear_progress.value = info.progress;
-
-                    if (info.action) {
-                        var grid_item = holds.filter(function(item) {
-                            return item.hold.id() == info.hold_details.id
-                        })[0];
-
-                        // there will be no grid item if the hold is off-page
-                        if (grid_item) {
-                            grid_item.post_clear = 
-                                egCore.strings['CLEAR_SHELF_ACTION_' + info.action];
-                        }
-                    }
-                });
+                if (resp.maximum) 
+                    $scope.clear_progress.max = resp.maximum;
+                if (resp.progress)
+                    $scope.clear_progress.value = resp.progress;
             }
+
         );
     }