lp1840287 Edit Floating Group Members
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / admin / server / floating-group / floating-group.component.ts
1 import {Pager} from '@eg/share/util/pager';
2 import {Component, Input, ViewChild} from '@angular/core';
3 import { Router, ActivatedRoute }    from '@angular/router';
4 import {IdlService, IdlObject} from '@eg/core/idl.service';
5 import {GridDataSource} from '@eg/share/grid/grid';
6 import {GridComponent} from '@eg/share/grid/grid.component';
7 import {ToastService} from '@eg/share/toast/toast.service';
8 import {PcrudService} from '@eg/core/pcrud.service';
9 import {OrgService} from '@eg/core/org.service';
10 import {PermService} from '@eg/core/perm.service';
11 import {AuthService} from '@eg/core/auth.service';
12 import { AdminPageComponent } from '../../../share/admin-page/admin-page.component';
13
14  @Component({
15      templateUrl: './floating-group.component.html'
16  })
17
18  export class FloatingGroupComponent extends AdminPageComponent {
19
20     idlClass = 'cfg';
21     @Input() sortField: string;
22     @Input() dialogSize: 'sm' | 'lg' = 'lg';
23
24     gridDataSource: GridDataSource = new GridDataSource();
25     
26     @ViewChild('grid', {static: true}) grid: GridComponent;
27
28     constructor(
29         route: ActivatedRoute,
30         idl: IdlService,
31         org: OrgService,
32         auth: AuthService,
33         pcrud: PcrudService,
34         perm: PermService,
35         toast: ToastService,
36         private router:Router
37     ) {
38         super(route, idl, org, auth, pcrud, perm, toast);
39     }
40
41     ngOnInit() {
42         super.ngOnInit();
43         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
44             const searchOps = {
45                 offset: pager.offset,
46                 limit: pager.limit,
47                 order_by: {}
48             };
49             return this.pcrud.retrieveAll("cfg", searchOps);
50         };
51         this.grid.onRowActivate.subscribe(
52             (idlThing: IdlObject) => {
53                 let idToEdit = idlThing.a[0];
54                 this.navigateToEditPage(idToEdit);
55             }
56         );
57     }
58
59     createNew = () => {
60         super.createNew();
61     };
62
63     editSelected = (floatingGroups: IdlObject[]) => {
64         let idToEdit = floatingGroups[0].a[0];
65         this.navigateToEditPage(idToEdit);
66     }
67
68     deleteSelected = (floatingGroups: IdlObject[]) => {
69         super.deleteSelected(floatingGroups);
70     }
71
72     navigateToEditPage(id: any) {
73         this.router.navigate(["/staff/admin/server/config/floating_group/" + id]);
74     }
75
76     // this was left mostly blank to ensure a modal does not open for edits
77     showEditDialog(idlThing: IdlObject): Promise<any> {
78         return;
79     }
80
81  }