LP1739288 user/stompro/lp1739288_report_invalid_barcodes_in_item_status
authorJosh Stompro <stompro@stompro.org>
Fri, 13 Sep 2019 14:54:18 +0000 (09:54 -0500)
committerJosh Stompro <stompro@stompro.org>
Fri, 13 Sep 2019 14:54:18 +0000 (09:54 -0500)
Add a summary report to the list of bad barcodes.

Lists count of bad barcodes, good barcodes and total barcodes.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index 55951b9..003dc0c 100644 (file)
       <ul>
         <li ng-repeat="badBarcode in context.itemsNotFound">{{badBarcode}}</li>
       </ul>
+      <span ng-show="context.itemsNotFoundBad > 0">[% l('Summary of file load, {{context.itemsNotFoundBad}} bad barcodes, {{context.itemsNotFoundGood}} good barcodes, {{context.itemsNotFoundTotal}} total barcodes.') %]</span>
     </div>
   </div>
 </div>
index 94e7024..e033f5d 100644 (file)
@@ -360,9 +360,15 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
 
     $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
         $scope.context.itemsNotFound = [];
+        $scope.context.itemsNotFoundBad = 0;
+        $scope.context.itemsNotFoundTotal = 0;
+        $scope.context.itemsNotFoundGood = 0;
+
         if (newVal && newVal != oldVal) {
             $scope.args.barcode = '';
             var barcodes = [];
+            var badbarcodes = 0;
+            var goodbarcodes = 0;
 
             angular.forEach(newVal.split(/\r?\n/), function(line) {
                 //remove all whitespace and commas
@@ -374,6 +380,7 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
                 if (!line) return;
                 barcodes.push(line);
             });
+            var totalbarcodes=barcodes.length;
 
             // Serialize copy retrieval since there may be many, many copies.
             function fetch_next_copy() {
@@ -386,12 +393,21 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD
                     if(itemSvc.copies[0]){  // Were any copies actually retrieved
                         copyGrid.selectItems([itemSvc.copies[0].index]);
                     }
+
+                    if(badbarcodes > 0){ // summarize load if badbarcodes found
+                        $scope.context.itemsNotFoundTotal=totalbarcodes;
+                        $scope.context.itemsNotFoundGood=totalbarcodes - badbarcodes;
+                        $scope.context.itemsNotFoundBad=badbarcodes;
+
+                        console.log('barcodesFromFile: badbarcodes',badbarcodes);
+                    }
                     return;
                 }
 
                 itemSvc.fetch(barcode).then(function(item) {
                     if (!item) {
                         $scope.context.itemsNotFound.push(barcode);
+                        badbarcodes++;
                     }
                     fetch_next_copy();
                 })