]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts
LP1850473: manual and automated eslint fixes
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / holds / grid.component.ts
1 import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
2 import {Location} from '@angular/common';
3 import {Observable, Observer, of, from} from 'rxjs';
4 import {concatMap} from 'rxjs/operators';
5 import {IdlObject} from '@eg/core/idl.service';
6 import {NetService} from '@eg/core/net.service';
7 import {OrgService} from '@eg/core/org.service';
8 import {AuthService} from '@eg/core/auth.service';
9 import {Pager} from '@eg/share/util/pager';
10 import {ServerStoreService} from '@eg/core/server-store.service';
11 import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid';
12 import {GridComponent} from '@eg/share/grid/grid.component';
13 import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
14 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
15 import {MarkDamagedDialogComponent
16 } from '@eg/staff/share/holdings/mark-damaged-dialog.component';
17 import {MarkMissingDialogComponent
18 } from '@eg/staff/share/holdings/mark-missing-dialog.component';
19 import {MarkDiscardDialogComponent
20 } from '@eg/staff/share/holdings/mark-discard-dialog.component';
21 import {HoldRetargetDialogComponent
22 } from '@eg/staff/share/holds/retarget-dialog.component';
23 import {HoldTransferDialogComponent} from './transfer-dialog.component';
24 import {HoldCancelDialogComponent} from './cancel-dialog.component';
25 import {HoldManageDialogComponent} from './manage-dialog.component';
26 import {PrintService} from '@eg/share/print/print.service';
27 import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
28 import {OrgSelectComponent} from '@eg/share/org-select/org-select.component';
29 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
30 import {HoldCopyLocationsDialogComponent} from './copy-locations-dialog.component';
31
32 /** Holds grid with access to detail page and other actions */
33
34 @Component({
35     selector: 'eg-holds-grid',
36     templateUrl: 'grid.component.html',
37     styles: ['.input-group > .form-control { width: auto; flex-grow: 0; }']
38 })
39 export class HoldsGridComponent implements OnInit {
40
41     // Hide the "Holds Count" header
42     @Input() hideHoldsCount = false;
43
44     // If either are set/true, the pickup lib selector will display
45     @Input() initialPickupLib: number | IdlObject;
46     @Input() hidePickupLibFilter: boolean;
47
48     // Setting a value here puts us into "pull list" mode.
49     @Input() pullListOrg: number;
50
51     // If true, only retrieve holds with a Hopeless Date
52     // and enable related Actions
53     @Input() hopeless: boolean;
54
55     // Grid persist key
56     @Input() persistKey: string;
57
58     @Input() preFetchSetting: string;
59
60     @Input() printTemplate: string;
61
62     // Adds a Place Hold grid toolbar button that emits
63     // placeHoldRequested on click.
64     @Input() showPlaceHoldButton = false;
65
66     // If set, all holds are fetched on grid load and sorting/paging all
67     // happens in the client.  If false, sorting and paging occur on
68     // the server.
69     @Input() enablePreFetch: boolean;
70
71     // How to sort when no sort parameters have been applied
72     // via grid controls.  This uses the eg-grid sort format:
73     // [{name: fname, dir: 'asc'}, {name: fname2, dir: 'desc'}]
74     @Input() defaultSort: any[];
75
76     // To pass through to the underlying eg-grid
77     @Input() showFields: string;
78
79     // Display bib record summary along the top of the detail page.
80     @Input() showRecordSummary = false;
81
82     // If true, avoid popping up the progress dialog.  Note the grid
83     // has it's own generic embedded 'loading' progress indicator.
84     @Input() noLoadProgress = false;
85
86     // Some default columns and actions do or don't make sense when
87     // displaying holds for a specific patron vs. e.g. a specific title.
88     @Input() patronFocused = false;
89
90     mode: 'list' | 'detail' | 'manage' = 'list';
91     initDone = false;
92     holdsCount: number;
93     pickupLib: IdlObject;
94     plCompLoaded = false;
95     gridDataSource: GridDataSource;
96     detailHold: any;
97     editHolds: number[];
98     transferTarget: number;
99     uncancelHoldCount: number;
100     copyLocationClass?: string;
101     copyLocationEntries: ComboboxEntry[] = [];
102     copyLocationIds: number[] = [];
103
104     @ViewChild('holdsGrid', { static: false }) private holdsGrid: GridComponent;
105     @ViewChild('progressDialog', { static: true })
106     private progressDialog: ProgressDialogComponent;
107     @ViewChild('transferDialog', { static: true })
108     private transferDialog: HoldTransferDialogComponent;
109     @ViewChild('markDamagedDialog', { static: true })
110     private markDamagedDialog: MarkDamagedDialogComponent;
111     @ViewChild('markMissingDialog', { static: true })
112     private markMissingDialog: MarkMissingDialogComponent;
113     @ViewChild('markDiscardDialog')
114     private markDiscardDialog: MarkDiscardDialogComponent;
115     @ViewChild('retargetDialog', { static: true })
116     private retargetDialog: HoldRetargetDialogComponent;
117     @ViewChild('cancelDialog', { static: true })
118     private cancelDialog: HoldCancelDialogComponent;
119     @ViewChild('manageDialog', { static: true })
120     private manageDialog: HoldManageDialogComponent;
121     @ViewChild('uncancelDialog') private uncancelDialog: ConfirmDialogComponent;
122     @ViewChild('copyLocationsDialog')
123     private copyLocationsDialog: HoldCopyLocationsDialogComponent;
124     @ViewChild('clearCopyLocationsDialog')
125     private clearCopyLocationsDialog: ConfirmDialogComponent;
126     @ViewChild('pullPickupLibFilter')
127     private pullPickupLibFilter: OrgSelectComponent;
128
129     // Bib record ID.
130     _recordId: number;
131     @Input() set recordId(id: number) {
132         this._recordId = id;
133         if (this.initDone) { // reload on update
134             this.holdsGrid.reload();
135         }
136     }
137
138     get recordId(): number {
139         return this._recordId;
140     }
141
142     _patronId: number;
143     @Input() set patronId(id: number) {
144         this._patronId = id;
145         if (this.initDone) {
146             this.holdsGrid.reload();
147         }
148     }
149     get patronId(): number {
150         return this._patronId;
151     }
152
153     // If true, show recently canceled holds only.
154     @Input() showRecentlyCanceled = false;
155
156     // Include holds fulfilled on or after hte provided date.
157     // If no value is passed, fulfilled holds are not displayed.
158     _showFulfilledSince: Date;
159     @Input() set showFulfilledSince(show: Date) {
160         this._showFulfilledSince = show;
161         if (this.initDone) { // reload on update
162             this.holdsGrid.reload();
163         }
164     }
165     get showFulfilledSince(): Date {
166         return this._showFulfilledSince;
167     }
168
169
170     cellTextGenerator: GridCellTextGenerator;
171
172     // Include holds marked Hopeless on or after this date.
173     _showHopelessAfter: Date;
174     @Input() set showHopelessAfter(show: Date) {
175         this._showHopelessAfter = show;
176         if (this.initDone) { // reload on update
177             this.holdsGrid.reload();
178         }
179     }
180
181     // Include holds marked Hopeless on or before this date.
182     _showHopelessBefore: Date;
183     @Input() set showHopelessBefore(show: Date) {
184         this._showHopelessBefore = show;
185         if (this.initDone) { // reload on update
186             this.holdsGrid.reload();
187         }
188     }
189
190     // Notify the caller the place hold button was clicked.
191     @Output() placeHoldRequested: EventEmitter<void> = new EventEmitter<void>();
192
193     constructor(
194         private ngLocation: Location,
195         private net: NetService,
196         private org: OrgService,
197         private store: ServerStoreService,
198         private auth: AuthService,
199         private printer: PrintService,
200         private holdings: HoldingsService
201     ) {
202         this.gridDataSource = new GridDataSource();
203         this.enablePreFetch = null;
204     }
205
206     ngOnInit() {
207         this.initDone = true;
208         this.pickupLib = this.org.get(this.initialPickupLib);
209
210         if (this.preFetchSetting) {
211             this.store.getItem(this.preFetchSetting).then(
212                 applied => this.enablePreFetch = Boolean(applied)
213             );
214         } else {
215             this.enablePreFetch = false;
216         }
217
218         if (!this.defaultSort) {
219             if (this.pullListOrg) {
220
221                 this.defaultSort = [
222                     {name: 'copy_location_order_position', dir: 'asc'},
223                     {name: 'acpl_name', dir: 'asc'},
224                     {name: 'ancp_label', dir: 'asc'}, // NOTE: API typo "ancp"
225                     {name: 'cn_label_sortkey', dir: 'asc'},
226                     {name: 'ancs_label', dir: 'asc'} // NOTE: API typo "ancs"
227                 ];
228
229             } else {
230                 this.defaultSort = [{name: 'request_time', dir: 'asc'}];
231             }
232         }
233
234         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
235
236             if (!this.hidePickupLibFilter || this.pullListOrg) {
237                 // When the pickup lib selector is active, avoid any
238                 // data fetches until it has settled on a default value.
239                 // Once the final value is applied, its onchange will
240                 // fire and we'll be back here with plCompLoaded=true.
241                 if (!this.plCompLoaded) {return of([]);}
242             }
243
244             sort = sort.length > 0 ? sort : this.defaultSort;
245             return this.fetchHolds(pager, sort);
246         };
247
248         // Text-ify function for cells that use display templates.
249         this.cellTextGenerator = {
250             title: row => row.title,
251             // eslint-disable-next-line eqeqeq
252             cp_barcode: row => (row.cp_barcode == null) ? '' : row.cp_barcode,
253             current_item: row => row.current_copy ? row.cp_barcode : '',
254             requested_item: row => this.isCopyHold(row) ? row.cp_barcode : '',
255             ucard_barcode: row => row.ucard_barcode,
256             hold_status: row => row.hold_status // TODO labels
257         };
258
259         if (this.pullListOrg) {
260             this.store.getItem('eg.holds.pull_list_filters').then(data => {
261                 if (data) {
262                     this.copyLocationClass = data.copyLocationClass;
263                     this.copyLocationEntries = data.copyLocationEntries;
264                     this.copyLocationIds = data.copyLocationIds;
265                     if (data.pickupLib) {
266                         this.pickupLib = this.org.get(data.pickupLib);
267                     }
268                 } else {
269                     this.copyLocationClass = 'acpl';
270                 }
271             });
272         }
273     }
274
275     // Returns true after all data/settings/etc required to render the
276     // grid have been fetched.
277     initComplete(): boolean {
278         return this.enablePreFetch !== null;
279     }
280
281     pickupLibChanged(org: IdlObject) {
282         this.pickupLib = org;
283         this.holdsGrid.reload();
284     }
285
286     pullPickupLibLoaded(): void {
287         this.plCompLoaded = true;
288         this.holdsGrid.reload();
289     }
290
291     resetPullPickupLibFilter(): void {
292         if (this.pickupLib) {
293             this.pullPickupLibFilter.reset();
294         }
295     }
296
297     pullPickupLibChanged(org: IdlObject): void {
298         if (org?.id() !== this.pickupLib?.id()) {
299             this.pickupLib = org;
300             this.savePullFilterSettings();
301             this.holdsGrid.reload();
302         }
303     }
304
305     openCopyLocationsDialog(): void {
306         this.copyLocationsDialog.init();
307         this.copyLocationsDialog.open({size: 'lg'}).subscribe(
308             ([fmClass, entries, ids]) => {
309                 this.copyLocationClass = fmClass;
310                 this.copyLocationEntries = entries;
311                 this.copyLocationIds = ids;
312                 this.savePullFilterSettings();
313                 this.holdsGrid.reload();
314             }
315         );
316     }
317
318     clearCopyLocations(): void {
319         if (!this.copyLocationEntries.length) {return;}
320         this.clearCopyLocationsDialog.open().subscribe(data => {
321             if (data) {
322                 this.copyLocationClass = 'acpl';
323                 this.copyLocationEntries = [];
324                 this.copyLocationIds = [];
325                 this.savePullFilterSettings();
326                 this.holdsGrid.reload();
327             }
328         });
329     }
330
331     pullListSettingsLoaded(): boolean {
332         return !!this.copyLocationClass;
333     }
334
335     savePullFilterSettings(): void {
336         this.store.setItem('eg.holds.pull_list_filters', {
337             copyLocationClass: this.copyLocationClass,
338             copyLocationEntries: this.copyLocationEntries,
339             copyLocationIds: this.copyLocationIds,
340             pickupLib: this.pickupLib ? +this.pickupLib.id() : undefined
341         });
342     }
343
344     pullListOrgChanged(org: IdlObject): void {
345         if (org && +org.id() !== +this.pullListOrg) {
346             this.pullListOrg = org.id();
347             this.holdsGrid.reload();
348         }
349     }
350
351     preFetchHolds(apply: boolean) {
352         this.enablePreFetch = apply;
353
354         if (apply) {
355             setTimeout(() => this.holdsGrid.reload());
356         }
357
358         if (this.preFetchSetting) {
359             // fire and forget
360             this.store.setItem(this.preFetchSetting, apply);
361         }
362     }
363
364     applyFilters(): any {
365
366         const filters: any = {};
367
368         if (this.copyLocationIds.length) {
369             filters['acpl.id'] = this.copyLocationIds;
370         }
371
372         if (this.pickupLib) {
373             filters.pickup_lib =
374                 this.org.descendants(this.pickupLib, true);
375         }
376
377         if (this.pullListOrg) {
378             filters.cancel_time = null;
379             filters.capture_time = null;
380             filters.frozen = 'f';
381
382             // cp.* fields are set for copy-level holds even if they
383             // have no current_copy.  Make sure current_copy is set.
384             filters.current_copy = {'is not': null};
385
386             // There are aliases for these (cp_status, cp_circ_lib),
387             // but the API complains when I use them.
388             filters['cp.status'] = {'in':{'select':{'ccs':['id']},'from':'ccs','where':{'holdable':'t','is_available':'t'}}};
389             filters['cp.circ_lib'] = this.pullListOrg;
390             // Avoid deleted copies AND this uses a database index on copy circ_lib where deleted is false.
391             filters['cp.deleted'] = 'f';
392
393             return filters;
394         }
395
396         if (this._showFulfilledSince) {
397             filters.fulfillment_time = this._showFulfilledSince.toISOString();
398         } else {
399             filters.fulfillment_time = null;
400         }
401
402
403         if (this.hopeless) {
404             filters['hopeless_holds'] = {
405                 'start_date' : this._showHopelessAfter
406                     ? (
407                 // FIXME -- consistency desired, string or object
408                         typeof this._showHopelessAfter === 'object'
409                             ? this._showHopelessAfter.toISOString()
410                             : this._showHopelessAfter
411                     )
412                     : '1970-01-01T00:00:00.000Z',
413                 'end_date' : this._showHopelessBefore
414                     ? (
415                 // FIXME -- consistency desired, string or object
416                         typeof this._showHopelessBefore === 'object'
417                             ? this._showHopelessBefore.toISOString()
418                             : this._showHopelessBefore
419                     )
420                     : (new Date()).toISOString()
421             };
422         }
423
424         if (this.recordId) {
425             filters.record_id = this.recordId;
426         }
427
428         if (this.patronId) {
429             filters.usr_id = this.patronId;
430         }
431
432         return filters;
433     }
434
435     fetchHolds(pager: Pager, sort: any[]): Observable<any> {
436
437         // We need at least one filter.
438         if (!this.recordId && !this.pickupLib && !this.patronId && !this.pullListOrg) {
439             return of([]);
440         }
441
442         const filters = this.applyFilters();
443
444         const orderBy: any = [];
445         if (sort.length > 0) {
446             sort.forEach(obj => {
447                 const subObj: any = {};
448                 subObj[obj.name] = {dir: obj.dir, nulls: 'last'};
449                 orderBy.push(subObj);
450             });
451         }
452
453         const limit = this.enablePreFetch ? null : pager.limit;
454         const offset = this.enablePreFetch ? 0 : pager.offset;
455         const options: any = {};
456         if (this.showRecentlyCanceled) {
457             options.recently_canceled = true;
458         } else {
459             filters.cancel_time = null;
460         }
461
462         let observer: Observer<any>;
463         const observable = new Observable(obs => observer = obs);
464
465         if (!this.noLoadProgress) {
466             // Note remaining dialog actions have no impact
467             this.progressDialog.open();
468         }
469
470         this.progressDialog.update({value: 0, max: 1});
471
472         let first = true;
473         let loadCount = 0;
474         this.net.request(
475             'open-ils.circ',
476             'open-ils.circ.hold.wide_hash.stream',
477             this.auth.token(), filters, orderBy, limit, offset, options
478         ).subscribe(
479             holdData => {
480
481                 if (first) { // First response is the hold count.
482                     this.holdsCount = Number(holdData);
483                     first = false;
484
485                 } else { // Subsequent responses are hold data blobs
486
487                     this.progressDialog.update(
488                         {value: ++loadCount, max: this.holdsCount});
489
490                     observer.next(holdData);
491                 }
492             },
493             (err: unknown) => {
494                 this.progressDialog.close();
495                 observer.error(err);
496             },
497             ()  => {
498                 this.progressDialog.close();
499                 observer.complete();
500             }
501         );
502
503         return observable;
504     }
505
506     metaRecordHoldsSelected(rows: IdlObject[]) {
507         let found = false;
508         rows.forEach( row => {
509             if (row.hold_type === 'M') {
510                 found = true;
511             }
512         });
513         return found;
514     }
515
516     nonTitleHoldsSelected(rows: IdlObject[]) {
517         let found = false;
518         rows.forEach( row => {
519             if (row.hold_type !== 'T') {
520                 found = true;
521             }
522         });
523         return found;
524     }
525
526     showDetails(rows: any[]) {
527         this.showDetail(rows[0]);
528     }
529
530     showHoldsForTitle(rows: any[]) {
531         if (rows.length === 0) { return; }
532
533         const url = this.ngLocation.prepareExternalUrl(
534             `/staff/catalog/record/${rows[0].record_id}/holds`);
535
536         window.open(url, '_blank');
537     }
538
539     showDetail(row: any) {
540         if (row) {
541             this.mode = 'detail';
542             this.detailHold = row;
543         }
544     }
545
546     showManager(rows: any[]) {
547         if (rows.length) {
548             this.mode = 'manage';
549             this.editHolds = rows.map(r => r.id);
550         }
551     }
552
553     handleModify(rowsModified: boolean) {
554         this.mode = 'list';
555
556         if (rowsModified) {
557             // give the grid a chance to render then ask it to reload
558             setTimeout(() => this.holdsGrid.reload());
559         }
560     }
561
562
563
564     showRecentCircs(rows: any[]) {
565         const copyIds = Array.from(new Set( rows.map(r => r.cp_id).filter( cp_id => Boolean(cp_id)) ));
566         copyIds.forEach( copyId => {
567             const url =
568                 '/eg/staff/cat/item/' + copyId + '/circ_list';
569             window.open(url, '_blank');
570         });
571     }
572
573     showPatron(rows: any[]) {
574         const usrIds = Array.from(new Set( rows.map(r => r.usr_id).filter( usr_id => Boolean(usr_id)) ));
575         usrIds.forEach( usrId => {
576             const url =
577                 '/eg/staff/circ/patron/' + usrId + '/checkout';
578             window.open(url, '_blank');
579         });
580     }
581
582     showOrder(rows: any[]) {
583         // Doesn't work in Typescript currently without compiler option:
584         //   const bibIds = [...new Set( rows.map(r => r.record_id) )];
585         const bibIds = Array.from(
586             new Set( rows.filter(r => r.hold_type !== 'M').map(r => r.record_id) ));
587         bibIds.forEach( bibId => {
588             const url =
589               '/eg/staff/acq/legacy/lineitem/related/' + bibId + '?target=bib';
590             window.open(url, '_blank');
591         });
592     }
593
594     addVolume(rows: any[]) {
595         const bibIds = Array.from(
596             new Set( rows.filter(r => r.hold_type !== 'M').map(r => r.record_id) ));
597         bibIds.forEach( bibId => {
598             this.holdings.spawnAddHoldingsUi(bibId);
599         });
600     }
601
602     showTitle(rows: any[]) {
603         const bibIds = Array.from(new Set( rows.map(r => r.record_id) ));
604         bibIds.forEach( bibId => {
605             // const url = '/eg/staff/cat/catalog/record/' + bibId;
606             const url = '/eg2/staff/catalog/record/' + bibId;
607             window.open(url, '_blank');
608         });
609     }
610
611     showManageDialog(rows: any[]) {
612         const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
613         if (holdIds.length > 0) {
614             this.manageDialog.holdIds = holdIds;
615             this.manageDialog.open({size: 'lg'}).subscribe(
616                 rowsModified => {
617                     if (rowsModified) {
618                         this.holdsGrid.reload();
619                     }
620                 }
621             );
622         }
623     }
624
625     showTransferDialog(rows: any[]) {
626         const holdIds = rows.filter(r => r.hold_type === 'T').map(r => r.id).filter(id => Boolean(id));
627         if (holdIds.length > 0) {
628             this.transferDialog.holdIds = holdIds;
629             this.transferDialog.open({}).subscribe(
630                 rowsModified => {
631                     if (rowsModified) {
632                         this.holdsGrid.reload();
633                     }
634                 }
635             );
636         }
637     }
638
639     async showMarkDamagedDialog(rows: any[]) {
640         const copyIds = rows.map(r => r.cp_id).filter(id => Boolean(id));
641         if (copyIds.length === 0) { return; }
642
643         let rowsModified = false;
644
645         const markNext = async(ids: number[]) => {
646             if (ids.length === 0) {
647                 return Promise.resolve();
648             }
649
650             this.markDamagedDialog.copyId = ids.pop();
651             return this.markDamagedDialog.open({size: 'lg'}).subscribe(
652                 ok => {
653                     if (ok) { rowsModified = true; }
654                     return markNext(ids);
655                 },
656                 (dismiss: unknown) => markNext(ids)
657             );
658         };
659
660         await markNext(copyIds);
661         if (rowsModified) {
662             this.holdsGrid.reload();
663         }
664     }
665
666     showMarkMissingDialog(rows: any[]) {
667         const copyIds = rows.map(r => r.cp_id).filter(id => Boolean(id));
668         if (copyIds.length > 0) {
669             this.markMissingDialog.copyIds = copyIds;
670             this.markMissingDialog.open({}).subscribe(
671                 rowsModified => {
672                     if (rowsModified) {
673                         this.holdsGrid.reload();
674                     }
675                 }
676             );
677         }
678     }
679
680     showMarkDiscardDialog(rows: any[]) {
681         const copyIds = rows.map(r => r.cp_id).filter(id => Boolean(id));
682         if (copyIds.length > 0) {
683             this.markDiscardDialog.copyIds = copyIds;
684             this.markDiscardDialog.open({}).subscribe(
685                 rowsModified => {
686                     if (rowsModified) {
687                         this.holdsGrid.reload();
688                     }
689                 }
690             );
691         }
692     }
693
694
695     showRetargetDialog(rows: any[]) {
696         const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
697         if (holdIds.length > 0) {
698             this.retargetDialog.holdIds = holdIds;
699             this.retargetDialog.open({}).subscribe(
700                 rowsModified => {
701                     if (rowsModified) {
702                         this.holdsGrid.reload();
703                     }
704                 }
705             );
706         }
707     }
708
709     showCancelDialog(rows: any[]) {
710         const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
711         if (holdIds.length > 0) {
712             this.cancelDialog.holdIds = holdIds;
713             this.cancelDialog.open({}).subscribe(
714                 rowsModified => {
715                     if (rowsModified) {
716                         this.holdsGrid.reload();
717                     }
718                 }
719             );
720         }
721     }
722
723     showUncancelDialog(rows: any[]) {
724         const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
725         if (holdIds.length === 0) { return; }
726         this.uncancelHoldCount = holdIds.length;
727
728         this.uncancelDialog.open().subscribe(confirmed => {
729             if (!confirmed) { return; }
730             this.progressDialog.open();
731
732             from(holdIds).pipe(concatMap(holdId => {
733                 return this.net.request(
734                     'open-ils.circ',
735                     'open-ils.circ.hold.uncancel',
736                     this.auth.token(), holdId
737                 );
738             // eslint-disable-next-line rxjs/no-nested-subscribe
739             })).subscribe(
740                 resp => {
741                     if (Number(resp) !== 1) {
742                         console.error('Failed uncanceling hold', resp);
743                     }
744                 },
745                 null,
746                 () => {
747                     this.progressDialog.close();
748                     this.holdsGrid.reload();
749                 }
750             );
751         });
752     }
753
754     printHolds() {
755         // Request a page with no limit to get all of the wide holds for
756         // printing.  Call requestPage() directly instead of grid.reload()
757         // since we may already have the data.
758
759         const pager = new Pager();
760         pager.offset = 0;
761         pager.limit = null;
762
763         if (this.gridDataSource.sort.length === 0) {
764             this.gridDataSource.sort = this.defaultSort;
765         }
766
767         this.gridDataSource.requestPage(pager).then(() => {
768             if (this.gridDataSource.data.length > 0) {
769                 this.printer.print({
770                     templateName: this.printTemplate || 'holds_for_bib',
771                     contextData: this.gridDataSource.data,
772                     printContext: 'default'
773                 });
774             }
775         });
776     }
777
778     isCopyHold(holdData: any): boolean {
779         if (holdData && holdData.hold_type) {
780             return holdData.hold_type.match(/C|R|F/) !== null;
781         }
782         return false;
783     }
784 }
785
786
787
788