LP1883171 & LP1940663: Update Staff client changes based on feedback user/dyrcona/lp1883171-lp1940663-inventory-date-changes
authorJason Stephenson <jason@sigio.com>
Sat, 8 Jan 2022 21:14:28 +0000 (16:14 -0500)
committerJason Stephenson <jason@sigio.com>
Sun, 9 Jan 2022 01:32:50 +0000 (20:32 -0500)
Modify the Item Staus view to check the new return values of the
update copy inventory function.

Fix toast handling in the list view to properly report success and failure.

Add toast handling to the single copy Item Status view to report
success and failure.

NOTE: More work could be done on the toasts to report number of
successful updates, etc.  I tried using the compileContent and trusted
HTML, but this lead to new errors that I couldn't decipher.

This work was sponsored by NOBLE.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/circ/services/item.js

index f200f6e..8980a65 100644 (file)
       "[% l('Updated most recent inventory data for selected items.') %]";
     s.FAIL_UPDATE_INVENTORY =
       "[% l('Failed to update recent inventory data for selected items.')%]";
+    s.SUCCESS_UPDATE_INVENTORY_SINGLE =
+      "[% l('Updated most recent inventory data for this item.') %]";
+    s.FAIL_UPDATE_INVENTORY_SINGLE =
+      "[% l('Failed to update recent inventory data for this item.')%]";
     s.ITEM_SUCCESSFULLY_MODIFIED =
       "[% l('Item successfully modified') %]";
     s.ITEMS_SUCCESSFULLY_MODIFIED =
index 8e21e25..1338a25 100644 (file)
@@ -52,8 +52,8 @@ angular.module('egItemStatus',
  * Parent scope for list and detail views
  */
 .controller('SearchCtrl', 
-       ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', 'egCirc',
-function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , egCirc) {
+      ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', 'egCirc', 'ngToast',
+function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , egCirc, ngToast) {
     $scope.args = {}; // search args
 
     // sub-scopes (search / detail-view) apply their version 
@@ -156,7 +156,12 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
     $scope.update_inventory = function() {
         itemSvc.updateInventory([$scope.args.copyId], null)
         .then(function(res) {
-            $timeout(function() { location.href = location.href; }, 1000);
+            if (res[0]) {
+                ngToast.create(egCore.strings.SUCCESS_UPDATE_INVENTORY_SINGLE);
+            } else {
+                ngToast.warning(egCore.strings.FAIL_UPDATE_INVENTORY_SINGLE);
+            }
+            $timeout(function() { location.href = location.href; }, 1500);
         });
     }
 
@@ -561,8 +566,7 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
     $scope.update_inventory = function() {
         var copy_list = gatherSelectedHoldingsIds();
         itemSvc.updateInventory(copy_list, $scope.gridControls.allItems()).then(function(res) {
-            if (res) {
-                $scope.gridControls.allItems(res);
+            if (res[0]) {
                 ngToast.create(egCore.strings.SUCCESS_UPDATE_INVENTORY);
             } else {
                 ngToast.warning(egCore.strings.FAIL_UPDATE_INVENTORY);
index 872c1b5..8070346 100644 (file)
@@ -212,14 +212,16 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
                                 {alci: ['inventory_workstation']}
                             }).then(function(alci) {
                                 //update existing grid rows
-                                item["latest_inventory.inventory_date"] = alci.inventory_date();
-                                item["latest_inventory.inventory_workstation.name"] =
-                                    alci.inventory_workstation().name();
+                                if (alci) {
+                                    item["latest_inventory.inventory_date"] = alci.inventory_date();
+                                    item["latest_inventory.inventory_workstation.name"] =
+                                        alci.inventory_workstation().name();
+                                }
                             });
                         }
                     });
                 });
-                return all_items || res;
+                return res;
             }
         });
     }