<ng-container *ngIf="loading">
<ng-container *ngTemplateOutlet="progress"></ng-container>
</ng-container>
- <eg-circ-grid #checkoutsGrid></eg-circ-grid>
+ <eg-circ-grid #checkoutsGrid (reloadRequested)="load()">
+ </eg-circ-grid>
</ng-template>
</li>
<ng-container *ngIf="displayAltList">
<ng-container *ngIf="loading">
<ng-container *ngTemplateOutlet="progress"></ng-container>
</ng-container>
- <eg-circ-grid #otherGrid></eg-circ-grid>
+ <eg-circ-grid #otherGrid (reloadRequested)="load()">
+ </eg-circ-grid>
</ng-container>
</ng-template>
</li>
<ng-container *ngIf="loading">
<ng-container *ngTemplateOutlet="progress"></ng-container>
</ng-container>
- <eg-circ-grid #nonCatGrid></eg-circ-grid>
+ <eg-circ-grid #nonCatGrid (reloadRequested)="load()">
+ </eg-circ-grid>
</ng-container>
</ng-container>
</ng-template>
mainList: number[] = [];
altList: number[] = [];
- displayLost: number; // 1 | 2 | 5 | 6;
- displayLongOverdue: number;
- displayClaimsReturned: number;
+ displayLost: number = null; // 1 | 2 | 5 | 6;
+ displayLongOverdue: number = null;
+ displayClaimsReturned: number = null;
fetchCheckedIn = true;
displayAltList = true;
promise.then(_ => this.loading = false);
}
- applyDisplaySettings() {
+ applyDisplaySettings(): Promise<any> {
+
+ if (this.displayLost !== null) {
+ // Logic already executed
+ return Promise.resolve();
+ }
+
return this.serverStore.getItemBatch([
'ui.circ.items_out.lost',
'ui.circ.items_out.longoverdue',
<eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
<eg-string #overdueString i18n-text text="Overdue"></eg-string>
<eg-due-date-dialog #dueDateDialog></eg-due-date-dialog>
+<eg-mark-damaged-dialog #markDamagedDialog [handleCheckin]="true">
+</eg-mark-damaged-dialog>
<ng-template #titleTemplate let-r="row">
<ng-container *ngIf="r.record">
(onClick)="editDueDate($event)">
</eg-grid-toolbar-action>
+ <eg-grid-toolbar-action
+ group="Mark" i18n-group i18n-label label="Mark Item Damaged"
+ (onClick)="showMarkDamagedDialog($event)"></eg-grid-toolbar-action>
+
<eg-grid-column [index]="true" path="index" [hidden]="true"
label="Row Index" i18n-label></eg-grid-column>
-import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Component, OnInit, Output, Input, ViewChild, EventEmitter} from '@angular/core';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {Observable, empty, of, from} from 'rxjs';
import {map, tap, switchMap} from 'rxjs/operators';
import {PrintService} from '@eg/share/print/print.service';
import {StringComponent} from '@eg/share/string/string.component';
import {DueDateDialogComponent} from './due-date-dialog.component';
+import {MarkDamagedDialogComponent
+ } from '@eg/staff/share/holdings/mark-damaged-dialog.component';
export interface CircGridEntry {
index: string; // class + id -- row index
@Input() persistKey: string;
@Input() printTemplate: string; // defaults to items_out
+ // Emitted when a grid action modified data in a way that could
+ // affect which cirulcations should appear in the grid. Caller
+ // should then refresh their data and call the load() or
+ // appendGridEntry() function.
+ @Output() reloadRequested: EventEmitter<void> = new EventEmitter<void>();
+
entries: CircGridEntry[] = null;
gridDataSource: GridDataSource = new GridDataSource();
cellTextGenerator: GridCellTextGenerator;
@ViewChild('copyAlertsDialog')
private copyAlertsDialog: CopyAlertsDialogComponent;
@ViewChild('dueDateDialog') private dueDateDialog: DueDateDialogComponent;
+ @ViewChild('markDamagedDialog')
+ private markDamagedDialog: MarkDamagedDialogComponent;
constructor(
private org: OrgService,
this.cellTextGenerator = {
title: row => row.title,
- barcode: row => row.copy ? row.copy.barcode() : ''
+ 'copy.barcode': row => row.copy ? row.copy.barcode() : ''
};
this.rowFlair = (row: CircGridEntry) => {
);
}
- getCopies(rows: any): IdlObject[] {
- return rows.filter(r => r.copy).map(r => r.copy);
+ // Which copies in the grid are selected.
+ getCopyIds(rows: CircGridEntry[], skipStatus?: number): number[] {
+ return this.getCopies(rows, skipStatus).map(c => Number(c.id()));
+ }
+
+ getCopies(rows: CircGridEntry[], skipStatus?: number): IdlObject[] {
+ let copies = rows.filter(r => r.copy).map(r => r.copy);
+ if (skipStatus) {
+ copies = copies.filter(
+ c => Number(c.status().id()) !== Number(skipStatus));
+ }
+ return copies;
}
getCircs(rows: any): IdlObject[] {
}
return row.overdue;
}
+
+ showMarkDamagedDialog(rows: CircGridEntry[]) {
+ const copyIds = this.getCopyIds(rows, 14 /* ignore damaged */);
+
+ if (copyIds.length === 0) { return; }
+
+ let rowsModified = false;
+
+ const markNext = (ids: number[]): Promise<any> => {
+ if (ids.length === 0) {
+ return Promise.resolve();
+ }
+
+ this.markDamagedDialog.copyId = ids.pop();
+
+ return this.markDamagedDialog.open({size: 'lg'})
+ .toPromise().then(ok => {
+ if (ok) { rowsModified = true; }
+ return markNext(ids);
+ });
+ };
+
+ markNext(copyIds).then(_ => {
+ if (rowsModified) {
+ this.emitReloadRequest();
+ }
+ });
+ }
+
+ emitReloadRequest() {
+ this.entries = null;
+ this.reloadRequested.emit();
+ }
}
extends DialogComponent {
@Input() copyId: number;
+
+ // If the item is checked out, ask the API to check it in first.
+ @Input() handleCheckin = false;
+
copy: IdlObject;
bibSummary: BibRecordSummary;
billingTypes: ComboboxEntry[];
markDamaged(args: any) {
this.chargeResponse = null;
- if (args && args.apply_fines === 'apply') {
+ if (args.apply_fines === 'apply') {
args.override_amount = this.newCharge;
args.override_btype = this.newBtype;
args.override_note = this.newNote;
}
+ if (this.handleCheckin) {
+ args.handle_checkin = true;
+ }
+
this.net.request(
'open-ils.circ', 'open-ils.circ.mark_item_damaged',
this.auth.token(), this.copyId, args