lp1712644 Prevent check out due date in past
authorKatlyn Beck <kbeck@catalyte.io>
Mon, 26 Nov 2018 21:23:48 +0000 (21:23 +0000)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 8 Jan 2019 21:21:06 +0000 (16:21 -0500)
- Prevents selecting past due date when checking out an item

Signed-off-by: Katlyn Beck <kbeck@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
modified:   Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
modified:   Open-ILS/web/js/ui/default/staff/services/ui.js

Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index d4fce7c..92946df 100644 (file)
@@ -30,7 +30,8 @@
           id="patron-checkout-barcode" type="text"/> 
 
         <input class="btn btn-default" type="submit" 
-          ng-class="{disabled : disable_checkout()}" value="[% l('Submit') %]"/>
+          ng-disabled="disable_checkout()"
+          value="[% l('Submit') %]"/>
 
       </div>
     </form>
           [% l('Specific Due Date') %]
         </label>
       </div> -->
+
       <div class="col-md-4">
-        <eg-date-input ng-model="checkoutArgs.due_date" ng-disabled="!date_options.has_sticky_date" show-time-picker></eg-date-input>
+        <eg-date-input min-date="minDate" out-of-range="outOfRange"
+          ng-model="checkoutArgs.due_date" ng-disabled="!date_options.has_sticky_date" show-time-picker>
+        </eg-date-input>
       </div>
 </div>
     </div>
index 1cbb05e..9c079f9 100644 (file)
@@ -19,6 +19,8 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         due_date : new Date()
     };
 
+    $scope.minDate = new Date();
+
     $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
         );
     }
 
index 59ff1c8..250105a 100644 (file)
@@ -1350,6 +1350,11 @@ https://stackoverflow.com/questions/24764802/angular-js-automatically-focus-inpu
                     minDate : $scope.minDate,
                     maxDate : $scope.maxDate
                 };
+                
+                $scope.outOfRange = false;
+
+                $scope.minDate = new Date();
+                $scope.outOfRange = false;
 
                 var maxDateObj = $scope.maxDate ? new Date($scope.maxDate) : null;
                 var minDateObj = $scope.minDate ? new Date($scope.minDate) : null;
@@ -1360,7 +1365,12 @@ https://stackoverflow.com/questions/24764802/angular-js-automatically-focus-inpu
                             var bad = false;
                             var newdate = new Date(n);
                             if (maxDateObj && newdate.getTime() > maxDateObj.getTime()) bad = true;
-                            if (minDateObj && newdate.getTime() < minDateObj.getTime()) bad = true;
+                            if (minDateObj && newdate.getTime() < minDateObj.getTime()) {
+                                if ((newdate.getMonth() != minDateObj.getMonth()) ||
+                                    (newdate.getDate() != minDateObj.getDate())) {
+                                    bad = true;
+                                }
+                            }
                             $scope.outOfRange = bad;
                         }
                     });