1 import {Component, Input, OnInit} 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';
9 templateUrl: './edit-floating-group.component.html'
12 export class EditFloatingGroupComponent implements OnInit {
14 dataSource: GridDataSource;
16 // defaultNewRecord is used when creating a new entry to give a default floating_group
17 defaultNewRecord: IdlObject;
19 // This is the ID of the floating group being edited currently
23 private route: ActivatedRoute,
24 private pcrud: PcrudService,
25 private idl: IdlService,
30 this.currentId = parseInt(this.route.snapshot.paramMap.get('id'), 10);
31 this.defaultNewRecord = this.idl.create('cfgm');
32 this.defaultNewRecord.floating_group(this.currentId);
33 this.dataSource = new GridDataSource();
35 this.dataSource.getRows = (pager: Pager, sort: any[]) => {
36 const orderBy: any = {};
38 orderBy.cfgm = sort[0].name + ' ' + sort[0].dir;
47 return this.pcrud.search('cfgm',
48 {floating_group: this.currentId}, searchOps);