LP1995623 Ang checkout prevents due dates in the past
authorBill Erickson <berickxx@gmail.com>
Thu, 3 Nov 2022 16:35:29 +0000 (12:35 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Sat, 28 Jan 2023 19:53:36 +0000 (14:53 -0500)
Prevent previous date selection in due date selector.

Additionally warn when a time in the past on the current day selected
and prevent checkout submission.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Susan Morrison <smorrison@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts

index 170562a..491be29 100644 (file)
         </button>
       </div>
     </div>
-    <eg-datetime-select [initialIso]="dueDate" 
+    <eg-datetime-select [initialIso]="dueDate" [noPast]="true"
       [readOnly]="dueDateOptions === 0" (onChangeAsIso)="setDueDate($event)">
     </eg-datetime-select>
+    <ng-container *ngIf="dueDateInvalid">
+      <span class="text-danger font-weight-bold ml-2" i18n>Due Date is Invalid</span>
+    </ng-container>
   </div>
 </div>
 
index 7d40790..839b0b6 100644 (file)
@@ -43,6 +43,7 @@ export class CheckoutComponent implements OnInit, AfterViewInit {
     cellTextGenerator: GridCellTextGenerator;
     dueDate: string;
     dueDateOptions: 0 | 1 | 2 = 0; // auto date; specific date; session date
+    dueDateInvalid = false;
     printOnComplete = true;
     strictBarcode = false;
 
@@ -155,6 +156,10 @@ export class CheckoutComponent implements OnInit, AfterViewInit {
 
     checkout(params?: CheckoutParams, override?: boolean): Promise<CheckoutResult> {
 
+        if (this.dueDateInvalid) {
+            return Promise.resolve(null);
+        }
+
         let barcode;
         const promise = params ? Promise.resolve(params) : this.collectParams();
 
@@ -256,6 +261,8 @@ export class CheckoutComponent implements OnInit, AfterViewInit {
     }
 
     setDueDate(iso: string) {
+        const date = new Date(Date.parse(iso));
+        this.dueDateInvalid = (date < new Date());
         this.dueDate = iso;
         this.store.setSessionItem('eg.circ.checkout.due_date', this.dueDate);
     }