From 5edd493912da4d816e765faea42caaa18af65557 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 16 Feb 2021 13:52:14 -0500 Subject: [PATCH] LP1904036 checkout continued; grid actions Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../app/staff/circ/patron/checkout.component.html | 15 +++- .../app/staff/circ/patron/checkout.component.ts | 79 ++++++++++++++++------ .../src/app/staff/circ/patron/patron.service.ts | 1 + .../staff/circ/patron/precat-dialog.component.ts | 6 +- 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.html index 54aacaafc7..ca96c1d5cc 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.html @@ -3,6 +3,7 @@ + -
+
@@ -83,6 +84,12 @@ + + + + @@ -97,10 +104,12 @@ + + +
- - diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts index 2b36ca76ec..b4b1fdf8df 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts @@ -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 { - 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(); + } + } + ); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts index dd66a15f41..3e63f8be21 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts @@ -13,6 +13,7 @@ export interface CircGridEntry { circ?: IdlObject; dueDate?: string; copyAlertCount: number; + nonCatCount: number; } const PATRON_FLESH_FIELDS = [ diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts index 8e79cff675..3b9ce8fea5 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/precat-dialog.component.ts @@ -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(); } + }); }); } } -- 2.11.0