<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"
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>
-
-
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',
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,
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);
}
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) => {
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 {
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);
}
}
}
}
})
}
+
+ 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();
+ }
+ }
+ );
+ }
}