LP1904036 precat checkouts
authorBill Erickson <berickxx@gmail.com>
Mon, 8 Feb 2021 21:41:55 +0000 (16:41 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:23 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
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
Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts

index 665034a..54aacaa 100644 (file)
@@ -35,9 +35,9 @@
         <input type="text" class="form-control" id="barcode-input"
           [placeholder]="checkoutNoncat ? '' : 'Barcode...'" i18n-placeholder
           [(ngModel)]="checkoutBarcode" [disabled]="checkoutNoncat != null"
-          i18n-aria-label aria-label="Barcode Input" (keyup.enter)="checkout()" />
+          i18n-aria-label aria-label="Barcode Input" (keydown.enter)="checkout()" />
         <div class="input-group-append">
-          <button class="btn btn-outline-dark" (keyup.enter)="checkout()" 
+          <button class="btn btn-outline-dark" (keydown.enter)="checkout()" 
             (click)="checkout()" i18n>Submit</button>
         </div>
       </div>
index 1217c56..2b36ca7 100644 (file)
@@ -92,14 +92,6 @@ export class CheckoutComponent implements OnInit {
 
         } else if (this.checkoutBarcode) {
 
-            if (this.copiesInFlight[this.checkoutBarcode]) {
-                console.log('Item ' +
-                    this.checkoutBarcode + ' is already mid-checkout');
-                return Promise.resolve(null);
-            }
-
-            this.copiesInFlight[this.checkoutBarcode] = true;
-
             params.copy_barcode = this.checkoutBarcode;
             if (this.dueDateOptions > 0) { params.due_date = this.dueDate; }
             return Promise.resolve(params);
@@ -108,10 +100,23 @@ export class CheckoutComponent implements OnInit {
         return Promise.resolve(null);
     }
 
-    checkout() {
-        this.collectParams()
+    checkout(params?: CheckoutParams, override?: boolean): Promise<CheckoutResult> {
 
-        .then((params: CheckoutParams) => {
+        const barcode = params.copy_barcode || '';
+
+        if (barcode) {
+
+            if (this.copiesInFlight[barcode]) {
+                console.debug('Item ' + barcode + ' is already mid-checkout');
+                return Promise.resolve(null);
+            }
+
+            this.copiesInFlight[barcode] = true;
+        }
+
+        const promise = params ? Promise.resolve(params) : this.collectParams();
+
+        promise.then((params: CheckoutParams) => {
             if (params) {
                 return this.circ.checkout(params);
             }
@@ -119,12 +124,12 @@ export class CheckoutComponent implements OnInit {
 
         .then((result: CheckoutResult) => {
             if (result) {
-                if (result.params.copy_barcode) {
-                    delete this.copiesInFlight[result.params.copy_barcode];
-                }
                 this.dispatchResult(result);
+                return result;
             }
-        });
+        })
+
+        .finally(() => delete this.copiesInFlight[barcode]);
     }
 
     dispatchResult(result: CheckoutResult) {
@@ -248,8 +253,13 @@ export class CheckoutComponent implements OnInit {
     }
 
     handlePrecat(result: CheckoutResult) {
-        this.precatDialog.open({size: 'lg'}).subscribe(values => {
-            console.log('precat values', values);
+        this.precatDialog.open().subscribe(values => {
+            if (values && values.dummy_title) {
+                const params = result.params;
+                params.precat = true;
+                Object.keys(values).forEach(key => params[key] = values[key]);
+                this.checkout(params);
+            }
         })
     }
 }
index 2b3d45e..5d1182c 100644 (file)
@@ -7,14 +7,44 @@
     </button>
   </div>
   <div class="modal-body">
+
     <div class="row">
+      <div class="col-lg-4" i18n>Title</div>
+      <div class="col-lg-8">
+        <input class="form-control" [(ngModel)]="values.dummy_title"
+          id='precat-title-input' i18n-placeholder placeholder="Title..."/>
+      </div>
+    </div>
+
+    <div class="row mt-2">
+      <div class="col-lg-4" i18n>Author</div>
+      <div class="col-lg-8">
+        <input class="form-control" [(ngModel)]="values.dummy_author"
+          i18n-placeholder placeholder="Author..."/>
+      </div>
+    </div>
+
+    <div class="row mt-2">
+      <div class="col-lg-4" i18n>ISBN</div>
+      <div class="col-lg-8">
+        <input class="form-control" [(ngModel)]="values.dummy_isbn"
+          i18n-placeholder placeholder="ISBN..."/>
+      </div>
+    </div>
+
+    <div class="row mt-2">
       <div class="col-lg-4" i18n>Circulation Modifier</div>
       <div class="col-lg-8">
-        <eg-combobox idlClass="ccm" [(ngModel)]="circModifier"></eg-combobox>
+        <eg-combobox idlClass="ccm" 
+          i18n-placeholder placeholder="Circulation Modifier..."
+          (onChange)="values.circ_modifier = $event ? $event.id : null">
+        </eg-combobox>
       </div>
     </div>
   </div>
   <div class="modal-footer">
-  <!-- has perm -->
+    <button type="button" class="btn btn-success" (click)="close(values)" 
+      [disabled]="!hasPerm || !values.dummy_title" i18n>Submit</button>
+    <button type="button" class="btn btn-warning" (click)="close()" i18n>Cancel</button>
   </div>
 </ng-template>
index d440876..8e79cff 100644 (file)
@@ -21,6 +21,13 @@ export class PrecatCheckoutDialogComponent extends DialogComponent implements On
     circModifier: ComboboxEntry;
     hasPerm = false;
 
+    values = {
+        dummy_title: null,
+        dummy_author: null,
+        dummy_isbn: null,
+        circ_modifier: null
+    };
+
     constructor(
         private perm: PermService,
         private modal: NgbModal) {
@@ -28,8 +35,13 @@ export class PrecatCheckoutDialogComponent extends DialogComponent implements On
     }
 
     ngOnInit() {
-        this.perm.hasWorkPermHere('CREATE_PRECAT')
-        .then(perms => this.hasPerm = perms['CREATE_PRECAT']);
+        this.onOpen$.subscribe(_ => {
+            this.perm.hasWorkPermHere('CREATE_PRECAT')
+            .then(perms => this.hasPerm = perms['CREATE_PRECAT']);
+
+            const node = document.getElementById('precat-title-input');
+            if (node) { node.focus(); }
+        });
     }
 }
 
index dee1b99..2acffcb 100644 (file)
@@ -13,14 +13,19 @@ import {AudioService} from '@eg/share/util/audio.service';
 
 // API parameter options
 export interface CheckoutParams {
-    due_date?: string;
     patron_id: number;
+    due_date?: string;
     copy_id?: number;
     copy_barcode?: string;
     noncat?: boolean;
     noncat_type?: number;
     noncat_count?: number;
     noop?: boolean;
+    precat?: boolean;
+    dummy_title?: string;
+    dummy_author?: string;
+    dummy_isbn?: string;
+    circ_modifier?: string;
 }
 
 export interface CheckoutResult {