LP1904036 checkout continued; grid actions
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Feb 2021 18:52:14 +0000 (13:52 -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/patron.service.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts

index 54aacaa..ca96c1d 100644 (file)
@@ -3,6 +3,7 @@
 
 <eg-precat-checkout-dialog #precatDialog [barcode]="checkoutBarcode">
 </eg-precat-checkout-dialog>
+<eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
 
 <eg-prompt-dialog #nonCatCount
   promptType="number"
@@ -12,7 +13,7 @@
   dialogBody="Enter the number of {{checkoutNoncat ? checkoutNoncat.name() : ''}} circulating">
 </eg-prompt-dialog>
 
-<div class="row mb-2 pb-2 border-bottom">
+<div class="row mb-3 pb-3 border-bottom">
   <div class="col-lg-12 d-flex">
     <div class="form-inline">
       <div class="input-group">
     <eg-grid #checkoutsGrid [dataSource]="gridDataSource" [sortable]="true"
       [useLocalSort]="true" [cellTextGenerator]="cellTextGenerator"
       persistKey="circ.patron.checkout">
+
+                       <eg-grid-toolbar-action
+                               i18n-group group="Add" i18n-label label="Add Item Alerts"
+                               (onClick)="openItemAlerts($event, 'create')">
+                       </eg-grid-toolbar-action>
+
       <eg-grid-column path="index" [index]="true" 
         label="Row Index" i18n-label [hidden]="true"></eg-grid-column>
       <eg-grid-column path="circ.id" label="Circ ID" i18n-label></eg-grid-column>
 
       <eg-grid-column path="title" label="Title" i18n-label 
         [cellTemplate]="titleTemplate"></eg-grid-column>
+
+      <eg-grid-column path="nonCatCount" label="Non-Cataloged Count"
+        i18n-label></eg-grid-column>
+
     </eg-grid>
   </div>
 </div>
 
 
-
-
index 2b36ca7..b4b1fdf 100644 (file)
@@ -17,6 +17,9 @@ import {StoreService} from '@eg/core/store.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
 import {PrecatCheckoutDialogComponent} from './precat-dialog.component';
 import {AudioService} from '@eg/share/util/audio.service';
+import {CopyAlertsDialogComponent} from '@eg/staff/share/holdings/copy-alerts-dialog.component';
+
+const SESSION_DUE_DATE = 'eg.circ.checkout.is_until_logout';
 
 @Component({
   templateUrl: 'checkout.component.html',
@@ -30,12 +33,18 @@ export class CheckoutComponent implements OnInit {
     gridDataSource: GridDataSource = new GridDataSource();
     cellTextGenerator: GridCellTextGenerator;
     dueDate: string;
-    copiesInFlight: {[barcode: string]: boolean} = {};
     dueDateOptions: 0 | 1 | 2 = 0; // auto date; specific date; session date
 
-    @ViewChild('nonCatCount') nonCatCount: PromptDialogComponent;
-    @ViewChild('checkoutsGrid') checkoutsGrid: GridComponent;
-    @ViewChild('precatDialog') precatDialog: PrecatCheckoutDialogComponent;
+    private copiesInFlight: {[barcode: string]: boolean} = {};
+
+    @ViewChild('nonCatCount')
+        private nonCatCount: PromptDialogComponent;
+    @ViewChild('checkoutsGrid')
+        private checkoutsGrid: GridComponent;
+    @ViewChild('precatDialog')
+        private precatDialog: PrecatCheckoutDialogComponent;
+    @ViewChild('copyAlertsDialog')
+        private copyAlertsDialog: CopyAlertsDialogComponent;
 
     constructor(
         private store: StoreService,
@@ -59,7 +68,7 @@ export class CheckoutComponent implements OnInit {
             title: row => row.title
         };
 
-        if (this.store.getSessionItem('eg.circ.checkout.is_until_logout')) {
+        if (this.store.getSessionItem(SESSION_DUE_DATE)) {
             this.dueDate = this.store.getSessionItem('eg.circ.checkout.due_date');
             this.toggleDateOptions(2);
         }
@@ -102,24 +111,25 @@ export class CheckoutComponent implements OnInit {
 
     checkout(params?: CheckoutParams, override?: boolean): Promise<CheckoutResult> {
 
-        const barcode = params.copy_barcode || '';
+        let barcode;
+        const promise = params ? Promise.resolve(params) : this.collectParams();
 
-        if (barcode) {
+        return promise.then((params: CheckoutParams) => {
+            if (!params) { return null; }
 
-            if (this.copiesInFlight[barcode]) {
-                console.debug('Item ' + barcode + ' is already mid-checkout');
-                return Promise.resolve(null);
-            }
+            barcode = params.copy_barcode || '';
 
-            this.copiesInFlight[barcode] = true;
-        }
+            if (barcode) {
 
-        const promise = params ? Promise.resolve(params) : this.collectParams();
+                if (this.copiesInFlight[barcode]) {
+                    console.debug('Item ' + barcode + ' is already mid-checkout');
+                    return null;
+                }
 
-        promise.then((params: CheckoutParams) => {
-            if (params) {
-                return this.circ.checkout(params);
+                this.copiesInFlight[barcode] = true;
             }
+
+            return this.circ.checkout(params);
         })
 
         .then((result: CheckoutResult) => {
@@ -166,13 +176,15 @@ export class CheckoutComponent implements OnInit {
             copy: result.copy,
             circ: result.circ,
             dueDate: null,
-            copyAlertCount: 0 // TODO
+            copyAlertCount: 0, // TODO
+            nonCatCount: 0
         };
 
         if (result.nonCatCirc) {
 
             entry.title = this.checkoutNoncat.name();
             entry.dueDate = result.nonCatCirc.duedate();
+            entry.nonCatCount = result.params.noncat_count;
 
         } else {
 
@@ -230,24 +242,24 @@ export class CheckoutComponent implements OnInit {
 
             if (value === 1) { // 1 or 2 -> 0
                 this.dueDateOptions = 0;
-                this.store.removeSessionItem('eg.circ.checkout.is_until_logout');
+                this.store.removeSessionItem(SESSION_DUE_DATE);
 
             } else if (this.dueDateOptions === 1) { // 1 -> 2
 
                 this.dueDateOptions = 2;
-                this.store.setSessionItem('eg.circ.checkout.is_until_logout', true);
+                this.store.setSessionItem(SESSION_DUE_DATE, true);
 
             } else { // 2 -> 1
 
                 this.dueDateOptions = 1;
-                this.store.removeSessionItem('eg.circ.checkout.is_until_logout');
+                this.store.removeSessionItem(SESSION_DUE_DATE);
             }
 
         } else {
 
             this.dueDateOptions = value;
             if (value === 2) {
-                this.store.setSessionItem('eg.circ.checkout.is_until_logout', true);
+                this.store.setSessionItem(SESSION_DUE_DATE, true);
             }
         }
     }
@@ -262,5 +274,28 @@ export class CheckoutComponent implements OnInit {
             }
         })
     }
+
+    selectedCopyIds(rows: CircGridEntry[]): number[] {
+        return rows
+            .filter(row => row.copy)
+            .map(row => Number(row.copy.id()));
+    }
+
+    openItemAlerts(rows: CircGridEntry[], mode: string) {
+        const copyIds = this.selectedCopyIds(rows);
+        if (copyIds.length === 0) { return; }
+
+        this.copyAlertsDialog.copyIds = copyIds;
+        this.copyAlertsDialog.mode = mode;
+        this.copyAlertsDialog.open({size: 'lg'}).subscribe(
+            modified => {
+                if (modified) {
+                    // TODO: verify the modiifed alerts are present
+                    // or go fetch them.
+                    this.checkoutsGrid.reload();
+                }
+            }
+        );
+    }
 }
 
index dd66a15..3e63f8b 100644 (file)
@@ -13,6 +13,7 @@ export interface CircGridEntry {
     circ?: IdlObject;
     dueDate?: string;
     copyAlertCount: number;
+    nonCatCount: number;
 }
 
 const PATRON_FLESH_FIELDS = [
index 8e79cff..3b9ce8f 100644 (file)
@@ -39,8 +39,10 @@ export class PrecatCheckoutDialogComponent extends DialogComponent implements On
             this.perm.hasWorkPermHere('CREATE_PRECAT')
             .then(perms => this.hasPerm = perms['CREATE_PRECAT']);
 
-            const node = document.getElementById('precat-title-input');
-            if (node) { node.focus(); }
+            setTimeout(() => {
+                const node = document.getElementById('precat-title-input');
+                if (node) { node.focus(); }
+            });
         });
     }
 }