From: Katlyn Beck Date: Mon, 26 Nov 2018 21:23:48 +0000 (+0000) Subject: lp1712644 Prevent check out due date in past X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4dbb87afaa8f55fe17f9b0f791d31109eb29cc21;p=evergreen%2Ftadl.git lp1712644 Prevent check out due date in past - Prevents selecting past due date when checking out an item - Prevents saving a due date with hatch when input date is invalid Signed-off-by: Katlyn Beck Signed-off-by: Kyle Huckins Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 index 65d56fb8ff..7cbe4927c7 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 @@ -30,7 +30,8 @@ id="patron-checkout-barcode" type="text"/> + ng-disabled="disable_checkout()" + value="[% l('Submit') %]"/> @@ -76,7 +77,9 @@ -->
- + +
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index d79811c705..3d1b60e2f7 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -19,6 +19,8 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , due_date : new Date() }; + $scope.minDate = new Date(); + $scope.outOfRange = false; $scope.gridDataProvider = egGridDataProvider.instance({ get : function(offset, count) { return this.arrayNotifier($scope.checkouts, offset, count); @@ -31,7 +33,8 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , patronSvc.current.active() == 'f' || patronSvc.current.deleted() == 't' || patronSvc.current.card().active() == 'f' || - patronSvc.fetchedWithInactiveCard() + patronSvc.fetchedWithInactiveCard() || + $scope.outOfRange == true ); } @@ -87,8 +90,12 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , }); $scope.$watch('checkoutArgs.due_date', function(newval) { - if ( $scope.date_options.is_until_logout ) { - egCore.hatch.setSessionItem('eg.circ.checkout.due_date', newval); + if ( $scope.date_options.is_until_logout && !isNaN(newval)) { + if (!$scope.outOfRange) { + egCore.hatch.setSessionItem('eg.circ.checkout.due_date', newval); + } else { + egCore.hatch.setSessionItem('eg.circ.checkout.due_date', $scope.checkoutArgs.due_date); + } } }); diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index 0fe9918e37..f8f7cd16a3 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -1356,13 +1356,12 @@ https://stackoverflow.com/questions/24764802/angular-js-automatically-focus-inpu if ($scope.outOfRange !== undefined && (maxDateObj || minDateObj)) { $scope.$watch('ngModel', function (n,o) { - if (n && n != o) { - var bad = false; - var newdate = new Date(n); - if (maxDateObj && newdate.getTime() > maxDateObj.getTime()) bad = true; - if (minDateObj && newdate.getTime() < minDateObj.getTime()) bad = true; - $scope.outOfRange = bad; - } + var bad = false; + var newdate = new Date(n); + if (isNaN(newdate.getTime())) bad = true; + if (maxDateObj && newdate.getTime() > maxDateObj.getTime()) bad = true; + if (minDateObj && newdate.getTime() < minDateObj.getTime()) bad = true; + $scope.outOfRange = bad; }); } }],