]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-items.component.ts
LP1818288 Grid checkboxes emit events
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / cat / vandelay / queue-items.component.ts
1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {Observable} from 'rxjs';
3 import {map} from 'rxjs/operators';
4 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
5 import {Pager} from '@eg/share/util/pager';
6 import {IdlObject} from '@eg/core/idl.service';
7 import {NetService} from '@eg/core/net.service';
8 import {AuthService} from '@eg/core/auth.service';
9 import {GridComponent} from '@eg/share/grid/grid.component';
10 import {GridDataSource} from '@eg/share/grid/grid';
11 import {VandelayService} from './vandelay.service';
12
13 @Component({
14   templateUrl: 'queue-items.component.html'
15 })
16 export class QueueItemsComponent {
17
18     queueType: string;
19     queueId: number;
20     filterImportErrors: boolean;
21
22     gridSource: GridDataSource;
23     @ViewChild('itemsGrid') itemsGrid: GridComponent;
24
25     constructor(
26         private router: Router,
27         private route: ActivatedRoute,
28         private net: NetService,
29         private auth: AuthService,
30         private vandelay: VandelayService) {
31
32         this.route.paramMap.subscribe((params: ParamMap) => {
33             this.queueId = +params.get('id');
34             this.queueType = params.get('qtype');
35         });
36
37         this.gridSource = new GridDataSource();
38
39         // queue API does not support sorting
40         this.gridSource.getRows = (pager: Pager) => {
41             return this.net.request(
42                 'open-ils.vandelay',
43                 'open-ils.vandelay.import_item.queue.retrieve',
44                 this.auth.token(), this.queueId, {
45                     with_import_error: this.filterImportErrors,
46                     offset: pager.offset,
47                     limit: pager.limit
48                 }
49             );
50         };
51     }
52
53     limitToImportErrors(checked: boolean) {
54         this.filterImportErrors = checked;
55         this.itemsGrid.reload();
56     }
57
58 }
59