lp1362743 holdings view duplicate barcodes
authorMike Risher <mrisher@catalyte.io>
Tue, 24 Mar 2020 16:40:02 +0000 (16:40 +0000)
committerJason Etheridge <jason@EquinoxInitiative.org>
Sat, 22 Aug 2020 05:08:23 +0000 (01:08 -0400)
Modify holdings view's "replace barcodes" UI so that it doesn't allow one
to enter a duplicate barcode.

Signed-off-by: Mike Risher <mrisher@catalyte.io>
Changes to be committed:
modified:   Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2
modified:   Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 62f9c8b..7e859fa 100644 (file)
@@ -1,5 +1,6 @@
 <div>
-<div class="row ">
+<script>window.duplicate_barcode_string = "[% l('Duplicate Barcode') %]";</script>
+<div class="row">
   <div class="col-md-1"></div>
   <div class="col-md-6">
     <h2 class="center-block">[% l('Replace Item Barcode') %]</h2>
       <div class="form-group">
         <label for="barcode2">[% l('Enter New Barcode for Item') %]</label>
         <input type="text" class="form-control" id="barcode2" select-me="focusBarcode2"
-          ng-model="barcode2"
+          ng-model="barcode2" ng-change="checkCurrentBarcode()"
           required placeholder="[% l('New Barcode...') %]">
+        <div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>
       </div>
-      <button type="submit" class="btn btn-default">[% l('Submit') %]</button>
+      <button type="submit" class="btn btn-default" ng-disabled="duplicate_barcode">[% l('Submit') %]</button>
       <button ng-if="isModal" class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
     </form>
   </div>
index 414f3ea..5678a98 100644 (file)
@@ -1045,11 +1045,27 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
                 controller:
                            ['$scope','$uibModalInstance',
                     function($scope , $uibModalInstance) {
+                        $scope.duplicate_barcode = false;
                         $scope.isModal = true;
                         $scope.focusBarcode = false;
                         $scope.focusBarcode2 = true;
                         $scope.barcode1 = cp.barcode();
 
+                        // check input to see if it's a duplicate barcode
+                        $scope.checkCurrentBarcode = function() {
+                            if (!$scope.duplicate_barcode_string) {
+                                $scope.duplicate_barcode_string = window.duplicate_barcode_string;
+                            }
+                            var searchParams = {
+                                deleted : 'f',
+                                'barcode' : $scope.barcode2,
+                                id : { '!=' : $scope.copyId }
+                            };
+                            egCore.pcrud.search('acp', searchParams).then(function (res) {
+                                $scope.duplicate_barcode = res;
+                            });
+                        }
+
                         $scope.updateBarcode = function() {
                             $scope.copyNotFound = false;
                             $scope.updateOK = false;