From b7e42d60141bdf73d104017e6ead3509d73088a9 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 25 Mar 2016 16:30:02 -0400 Subject: [PATCH] LP#1570091: webstaff: always check for duplciate barcodes ... and disallow saving if critical data is missing Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson --- .../templates/staff/cat/volcopy/t_edit.tt2 | 8 ++-- .../src/templates/staff/share/t_autogrid.tt2 | 2 +- .../js/ui/default/staff/cat/volcopy/app.js | 41 ++++++++++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2 index e110bbfd43..95e8e5083f 100644 --- a/Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2 @@ -55,7 +55,7 @@
- @@ -109,7 +109,7 @@ - @@ -143,9 +143,9 @@ - - diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index 3ffd9f239c..e96e2fbfc9 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -15,7 +15,7 @@ diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index ceedfb92ee..40efacce46 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -240,9 +240,9 @@ function(egCore , $q) { service.copies.push(cp); } - service.checkDuplicateBarcode = function(bc) { + service.checkDuplicateBarcode = function(bc, id) { var final = false; - return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc }) + return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc, id : { '!=' : id } }) .then( function () { return final }, function () { return final }, @@ -281,6 +281,7 @@ function(egCore , $q) { cp.opac_visible('t'); cp.ref('f'); cp.mint_condition('t'); + cp.empty_barcode = true; var status_setting = isFastAdd ? 'cat.default_copy_status_fast' : @@ -328,20 +329,20 @@ function(egCore , $q) { $scope.duplicate_barcode_string = window.duplicate_barcode_string; $scope.empty_barcode_string = window.empty_barcode_string; + if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true; + $scope.nextBarcode = function (i) { $scope.focusNext(i, $scope.barcode); } $scope.updateBarcode = function () { if ($scope.barcode != '') { - $scope.empty_barcode = false; + $scope.copy.empty_barcode = $scope.empty_barcode = false; $scope.barcode_has_error = !Boolean(itemSvc.checkBarcode($scope.barcode)); - if ($scope.copy.isnew()) { - itemSvc.checkDuplicateBarcode($scope.barcode) - .then(function (state) { $scope.duplicate_barcode = state }); - } + itemSvc.checkDuplicateBarcode($scope.barcode, $scope.copy.id()) + .then(function (state) { $scope.copy.duplicate_barcode = $scope.duplicate_barcode = state }); } else { - $scope.empty_barcode = true; + $scope.copy.empty_barcode = $scope.empty_barcode = true; } $scope.copy.barcode($scope.barcode); @@ -427,6 +428,7 @@ function(egCore , $q) { controller : ['$scope','itemSvc','egCore', function ( $scope , itemSvc , egCore ) { $scope.callNumber = $scope.copies[0].call_number(); + if (!$scope.callNumber.label()) $scope.callNumber.emtpy_label = true; $scope.empty_label = false; $scope.empty_label_string = window.empty_label_string; @@ -557,9 +559,9 @@ function(egCore , $q) { $scope.updateLabel = function () { if ($scope.label == '') { - $scope.empty_label = true; + $scope.callNumber.empty_label = $scope.empty_label = true; } else { - $scope.empty_label = false; + $scope.callNumber.empty_label = $scope.empty_label = false; } angular.forEach($scope.copies, function(cp) { cp.call_number().label($scope.label); @@ -1209,6 +1211,25 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.workingGridDataProvider.refresh(); }); + $scope.can_save = false; + function check_saveable () { + var can_save = true; + angular.forEach( + itemSvc.copies, + function (i) { + if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) + can_save = false; + } + ); + + $scope.can_save = can_save; + } + + $scope.disableSave = function () { + check_saveable(); + return !$scope.can_save; + } + $scope.focusNextFirst = function(prev_lib,prev_bc) { var n; var yep = false; -- 2.43.2