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