lp1840287 Edit Floating Group Members
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / admin / server / floating-group / edit-floating-group.component.ts
1 import {Component, Input} from '@angular/core';
2 import {Router, ActivatedRoute} from '@angular/router';
3 import {GridDataSource} from '@eg/share/grid/grid';
4 import {Pager} from '@eg/share/util/pager';
5 import {PcrudService} from '@eg/core/pcrud.service';
6 import {IdlObject, IdlService } from '@eg/core/idl.service';
7
8  @Component({
9      templateUrl: './edit-floating-group.component.html'
10  })
11
12  export class EditFloatingGroupComponent {
13
14     @Input() sortField: string;
15     @Input() dataSource: GridDataSource;
16     @Input() dialogSize: 'sm' | 'lg' = 'lg';
17
18     // defaultNewRecord is used when creating a new entry to give a default floating_group
19     defaultNewRecord: IdlObject;
20
21     // This is the ID of the floating group being edited currently
22     currentId: number;
23
24     constructor(
25         private route: ActivatedRoute,
26         private pcrud: PcrudService,
27         private idl: IdlService,
28     ) {
29     }
30
31     ngOnInit() {
32         this.currentId = parseInt(this.route.snapshot.paramMap.get('id'));
33         this.defaultNewRecord = this.idl.create('cfgm');
34         this.defaultNewRecord.floating_group(this.currentId);
35         this.dataSource = new GridDataSource();
36         this.dataSource.getRows = (pager: Pager, sort: any[]) => {
37             const searchOps = {
38                 offset: pager.offset,
39                 limit: pager.limit,
40                 order_by: {}
41             };
42             return this.pcrud.search("cfgm", {floating_group: this.currentId}, searchOps);
43         };
44     }
45  }