LP1883171 & LP1940663: Basic staff client modifications
authorJason Stephenson <jason@sigio.com>
Sun, 7 Nov 2021 21:00:34 +0000 (16:00 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 24 Mar 2022 21:26:22 +0000 (17:26 -0400)
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>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Mike Rylander <mrylander@gmail.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/circ.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 32fc43d..3372777 100644 (file)
@@ -289,7 +289,6 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
         data.record = payload.record;
         data.acp = payload.copy;
         data.acn = payload.volume ?  payload.volume : payload.copy ? payload.copy.call_number() : null;
-        data.alci = egCore.idl.toHash(payload.latest_inventory, true);
         data.au = payload.patron;
         data.transit = payload.transit;
         data.status = payload.status;
@@ -302,13 +301,6 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
 
         if (payload.circ) data.duration = payload.circ.duration();
         if (payload.circ) data.circ_lib = payload.circ.circ_lib();
-        if (payload.do_inventory_update) {
-            if (payload.latest_inventory.id()) {
-                egCore.pcrud.update(payload.latest_inventory);
-            } else {
-                egCore.pcrud.create(payload.latest_inventory);
-            }
-        }
 
         // for checkin, the mbts lives on the main circ
         if (payload.circ && payload.circ.billable_transaction())
@@ -1659,12 +1651,11 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
 
         var final_resp = {evt : evt, params : params, options : options};
 
-        var copy, hold, transit, latest_inventory;
+        var copy, hold, transit;
         if (evt[0].payload) {
             copy = evt[0].payload.copy;
             hold = evt[0].payload.hold;
             transit = evt[0].payload.transit;
-            latest_inventory = evt[0].payload.latest_inventory;
         }
 
         // track the barcode regardless of whether it's valid
index 56d82bf..8070346 100644 (file)
@@ -200,7 +200,7 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast
         if (copy_list.length == 0) return;
         return egCore.net.request(
             'open-ils.circ',
-            'open-ils.circ.circulation.update_latest_inventory',
+            'open-ils.circ.circulation.update_copy_inventory',
             egCore.auth.token(), {copy_list: copy_list}
         ).then(function(res) {
             if (res) {
@@ -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;
             }
         });
     }