<eg-progress-dialog #progressDialog></eg-progress-dialog>
<eg-barcode-select #barcodeSelect></eg-barcode-select>
-
-<eg-precat-checkout-dialog #precatDialog [barcode]="checkoutBarcode">
-</eg-precat-checkout-dialog>
<eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
<eg-prompt-dialog #nonCatCount
import {Pager} from '@eg/share/util/pager';
import {StoreService} from '@eg/core/store.service';
import {ServerStoreService} from '@eg/core/server-store.service';
-import {PrecatCheckoutDialogComponent} from '@eg/staff/share/circ/precat-dialog.component';
import {AudioService} from '@eg/share/util/audio.service';
import {CopyAlertsDialogComponent
} from '@eg/staff/share/holdings/copy-alerts-dialog.component';
private nonCatCount: PromptDialogComponent;
@ViewChild('checkoutsGrid')
private checkoutsGrid: GridComponent;
- @ViewChild('precatDialog')
- private precatDialog: PrecatCheckoutDialogComponent;
@ViewChild('copyAlertsDialog')
private copyAlertsDialog: CopyAlertsDialogComponent;
@ViewChild('barcodeSelect')
}
dispatchResult(result: CheckoutResult) {
-
if (result.success) {
this.gridifyResult(result);
this.resetForm();
return;
}
-
- switch (result.evt.textcode) {
- case 'ITEM_NOT_CATALOGED':
- this.handlePrecat(result);
- break;
- }
}
resetForm() {
}
}
- handlePrecat(result: CheckoutResult) {
- 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);
- }
- });
- }
-
selectedCopyIds(rows: CircGridEntry[]): number[] {
return rows
.filter(row => row.copy)
</eg-staff-banner>
</ng-container>
+<eg-circ-components></eg-circ-components>
+
<ng-container *ngIf="context.patron">
<eg-staff-banner i18n-bannerText bannerText="
{{patronService.namePart(context.patron, 'family_name')}},
import {DueDateDialogComponent} from './due-date-dialog.component';
import {PrecatCheckoutDialogComponent} from './precat-dialog.component';
import {ClaimsReturnedDialogComponent} from './claims-returned-dialog.component';
+import {CircComponentsComponent} from './components.component';
@NgModule({
declarations: [
CircGridComponent,
+ CircComponentsComponent,
DueDateDialogComponent,
PrecatCheckoutDialogComponent,
ClaimsReturnedDialogComponent
],
exports: [
CircGridComponent,
- PrecatCheckoutDialogComponent
+ CircComponentsComponent
],
providers: [
CircService
import {AuthService} from '@eg/core/auth.service';
import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
import {AudioService} from '@eg/share/util/audio.service';
+import {PrecatCheckoutDialogComponent
+ } from '@eg/staff/share/circ/precat-dialog.component';
// API parameter options
export interface CheckoutParams {
- patron_id: number;
+ patron_id?: number;
due_date?: string;
copy_id?: number;
copy_barcode?: string;
evt: EgEvent;
params: CheckoutParams;
success: boolean;
+ canceled?: boolean;
copy?: IdlObject;
circ?: IdlObject;
- nonCatCirc: IdlObject;
+ nonCatCirc?: IdlObject;
record?: IdlObject;
}
static resultIndex = 0;
nonCatTypes: IdlObject[] = null;
+ precatDialog: PrecatCheckoutDialogComponent;
constructor(
private audio: AudioService,
.then(result => this.processCheckoutResult(params, result));
}
+ renew(params: CheckoutParams, override?: boolean): Promise<CheckoutResult> {
+
+ console.debug('renewing out with', params);
+
+ let method = 'open-ils.circ.renew';
+ if (override) { method += '.override'; }
+
+ return this.net.request(
+ 'open-ils.circ', method,
+ this.auth.token(), params).toPromise()
+ .then(result => this.processCheckoutResult(params, result));
+ }
+
processCheckoutResult(
params: CheckoutParams, response: any): Promise<CheckoutResult> {
nonCatCirc: payload.noncat_circ
};
+ switch (evt.textcode) {
+ case 'ITEM_NOT_CATALOGED':
+ return this.handlePrecat(result);
+ }
+
return Promise.resolve(result);
}
+ handlePrecat(result: CheckoutResult): Promise<CheckoutResult> {
+ this.precatDialog.barcode = result.params.copy_barcode;
+
+ return this.precatDialog.open().toPromise().then(values => {
+
+ if (values && values.dummy_title) {
+ const params = result.params;
+ params.precat = true;
+ Object.keys(values).forEach(key => params[key] = values[key]);
+ return this.checkout(params);
+ }
+
+ result.canceled = true;
+ return Promise.resolve(result);
+ });
+ }
+
checkin(params: CheckinParams, override?: boolean): Promise<CheckinResult> {
console.debug('checking in with', params);
// alert, etc.
}
+ const success =
+ evt.textcode.match(/SUCCESS|NO_CHANGE|ROUTE_ITEM/) !== null;
+
const result: CheckinResult = {
index: CircService.resultIndex++,
evt: evt,
params: params,
- success: evt.textcode === 'SUCCESS', // or route, no change, etc.
+ success: success,
circ: payload.circ,
copy: payload.copy,
record: payload.record
// The provided params (minus the copy_id) will be used
// for all items.
+ checkoutBatch(copyIds: number[], params: CheckoutParams): Observable<CheckoutResult> {
+ if (copyIds.length === 0) { return empty(); }
+ const source = from(copyIds);
+
+ return source.pipe(concatMap(id => {
+ const cparams = Object.assign(params, {}); // clone
+ cparams.copy_id = id;
+ return from(this.checkout(cparams));
+ }));
+ }
+
+ // The provided params (minus the copy_id) will be used
+ // for all items.
+ renewBatch(copyIds: number[], params?: CheckoutParams): Observable<CheckoutResult> {
+ if (copyIds.length === 0) { return empty(); }
+
+ if (!params) { params = {}; }
+
+ const source = from(copyIds);
+
+ return source.pipe(concatMap(id => {
+ const cparams = Object.assign(params, {}); // clone
+ cparams.copy_id = id;
+ return from(this.renew(cparams));
+ }));
+ }
+
+ // The provided params (minus the copy_id) will be used
+ // for all items.
checkinBatch(copyIds: number[], params?: CheckinParams): Observable<CheckinResult> {
if (copyIds.length === 0) { return empty(); }
--- /dev/null
+
+<eg-precat-checkout-dialog #precatDialog></eg-precat-checkout-dialog>
+
+
--- /dev/null
+import {Component, AfterViewInit, Output, Input, ViewChild, EventEmitter} from '@angular/core';
+import {CircService} from './circ.service';
+import {PrecatCheckoutDialogComponent
+ } from '@eg/staff/share/circ/precat-dialog.component';
+
+/* Container component for sub-components used by circulation actions.
+ *
+ * The CircService has to launch various dialogs for processing checkouts,
+ * checkins, etc. The service itself cannot contain components directly,
+ * so we compile them here and provide references.
+ * */
+
+@Component({
+ templateUrl: 'components.component.html',
+ selector: 'eg-circ-components'
+})
+export class CircComponentsComponent implements AfterViewInit {
+
+ @ViewChild('precatDialog')
+ private precatDialog: PrecatCheckoutDialogComponent;
+
+ constructor(private circ: CircService) {}
+
+ ngAfterViewInit() {
+ this.circ.precatDialog = this.precatDialog;
+ }
+}
+
(onClick)="markLost($event)"></eg-grid-toolbar-action>
<!-- .subscribe() nudges the observable to run -->
- <eg-grid-toolbar-action i18n-label label="Checkin"
+ <eg-grid-toolbar-action
+ group="Circulation" i18n-group i18n-label label="Checkin"
(onClick)="checkin($event).subscribe()">
</eg-grid-toolbar-action>
+ <eg-grid-toolbar-action group="Circulation" i18n-group
+ i18n-label label="Renew" (onClick)="renew($event)">
+ </eg-grid-toolbar-action>
+
<eg-grid-column [index]="true" path="index" [hidden]="true"
label="Row Index" i18n-label></eg-grid-column>
return this.progressDialog;
}
+ renew(rows: CircGridEntry[]) {
+
+ const dialog = this.openProgressDialog(rows);
+ const params: CheckoutParams = {};
+
+ return this.circ.renewBatch(this.getCopyIds(rows))
+ .subscribe(
+ result => dialog.increment(),
+ err => console.error(err),
+ () => {
+ dialog.close();
+ this.emitReloadRequest();
+ }
+ );
+ }
+
// Same params will be used for each copy
checkin(rows: CircGridEntry[], params?:
CheckinParams, noReload?: boolean): Observable<CheckinResult> {