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