<eg-hold-retarget-dialog #retargetDialog></eg-hold-retarget-dialog>
<eg-hold-cancel-dialog #cancelDialog></eg-hold-cancel-dialog>
<eg-hold-manage-dialog #manageDialog></eg-hold-manage-dialog>
+<eg-confirm-dialog #uncancelDialog
+ i18n-dialogTitle i18n-dialogBody
+ i18n-dialogTitle="Un-Cancel Holds"
+ dialogBody="Un-Cancel {{uncancelHoldCount}} hold(s)?"
+></eg-confirm-dialog>
<ng-template #statusTemplate let-hold="row">
<ng-container [ngSwitch]="hold.hold_status">
i18n-label label="Show Last Few Circulations" group="Item" i18n-group
(onClick)="showRecentCircs($event)"></eg-grid-toolbar-action>
- <eg-grid-toolbar-action
+ <eg-grid-toolbar-action *ngIf="!patronFocused"
i18n-label label="Retrieve Patron" group="Patron" i18n-group
(onClick)="showPatron($event)">
</eg-grid-toolbar-action>
i18n-group group="Hold" i18n-label label="Find Another Target"
(onClick)="showRetargetDialog($event)"></eg-grid-toolbar-action>
- <eg-grid-toolbar-action
+ <eg-grid-toolbar-action *ngIf="!showRecentlyCanceled"
i18-group group="Hold" i18n-label label="Cancel Hold"
- (onClick)="showCancelDialog($event)"></eg-grid-toolbar-action>
+ (onClick)="showUncancelDialog($event)"></eg-grid-toolbar-action>
+
+ <eg-grid-toolbar-action *ngIf="showRecentlyCanceled"
+ i18n-label label="Un-Cancel Hold(s)" group="Hold" i18n-group
+ (onClick)="showUncancelDialog($event)">
+ </eg-grid-toolbar-action>
<eg-grid-toolbar-action
i18-group group="Hold" i18n-label label="Print Holds"
import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {Location} from '@angular/common';
-import {Observable, Observer, of} from 'rxjs';
+import {Observable, Observer, of, from} from 'rxjs';
+import {concatMap} from 'rxjs/operators';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {OrgService} from '@eg/core/org.service';
import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
import {GridComponent} from '@eg/share/grid/grid.component';
import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
+import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {MarkDamagedDialogComponent
} from '@eg/staff/share/holdings/mark-damaged-dialog.component';
import {MarkMissingDialogComponent
// has it's own generic embedded 'loading' progress indicator.
@Input() noLoadProgress = false;
+ // Some default columns and actions do or don't make sense when
+ // displaying holds for a specific patron vs. e.g. a specific title.
+ @Input() patronFocused = false;
+
mode: 'list' | 'detail' | 'manage' = 'list';
initDone = false;
holdsCount: number;
detailHold: any;
editHolds: number[];
transferTarget: number;
+ uncancelHoldCount: number;
@ViewChild('holdsGrid', { static: false }) private holdsGrid: GridComponent;
@ViewChild('progressDialog', { static: true })
private cancelDialog: HoldCancelDialogComponent;
@ViewChild('manageDialog', { static: true })
private manageDialog: HoldManageDialogComponent;
+ @ViewChild('uncancelDialog') private uncancelDialog: ConfirmDialogComponent;
// Bib record ID.
_recordId: number;
}
}
+ showUncancelDialog(rows: any[]) {
+ const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
+ if (holdIds.length === 0) { return; }
+ this.uncancelHoldCount = holdIds.length;
+
+ this.uncancelDialog.open().subscribe(confirmed => {
+ if (!confirmed) { return; }
+ this.progressDialog.open();
+
+ from(holdIds).pipe(concatMap(holdId => {
+ return this.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.hold.uncancel',
+ this.auth.token(), holdId
+ )
+ })).subscribe(
+ resp => {
+ if (Number(resp) !== 1) {
+ console.error('Failed uncanceling hold', resp);
+ }
+ },
+ null,
+ () => {
+ this.progressDialog.close();
+ this.holdsGrid.reload();
+ }
+ );
+ });
+ }
+
printHolds() {
// Request a page with no limit to get all of the wide holds for
// printing. Call requestPage() directly instead of grid.reload()