import {Component, ViewEncapsulation} from '@angular/core'; import {GridOptions} from 'ag-grid/main'; import { TdLoadingService } from '@covalent/core'; import { StatementBase } from '../../../models/statement.base'; import { RoadToCategory } from '../../../models/road-to-category'; import { EditorComponent } from '../../../helpers/editor.component'; import { RendererComponent } from '../../../helpers/renderer.component'; import { RoadToCategoryService } from '../../../services/road-to-category.service'; import { RoadToCategoryCreateService } from '../../../services/road-to-category-create.service'; import { RegionSelectList } from '../../../models/region-select-list'; import { RoadSelectList } from '../../../models/road-select-list'; import { RoadCategorySelectList } from '../../../models/road-category-select-list'; import { routerTransition } from '../../../animations/router.animation'; @Component({ selector: 'road-to-category', templateUrl: 'road-to-category.component.html', styleUrls: ['road-to-category.scss'], encapsulation: ViewEncapsulation.None, }) export class RoadToCategoryComponent extends StatementBase { public regions: RegionSelectList[]; public roads: RoadSelectList[]; public roadCategory: RoadCategorySelectList[]; constructor( protected service: RoadToCategoryService, protected dataService: RoadToCategoryCreateService, protected loadingService: TdLoadingService, ) { super(); } protected createColumnDefs(): any[] { return [ { headerName: '#', width: 30, checkboxSelection: true, suppressSorting: true, suppressMenu: true, pinned: true, }, { headerName: 'ID', field: 'id', }, { headerName: 'Назва дороги', field: 'roadId', editable: true, cellEditorFramework: EditorComponent, cellRendererFramework: RendererComponent, cellEditorParams: { data: this.roads, valueCol: 'roadId', labelCol: 'name', }, }, { headerName: 'Область', field: 'regionId', editable: true, cellEditorFramework: EditorComponent, cellRendererFramework: RendererComponent, cellEditorParams: { data: this.regions, valueCol: 'regionId', labelCol: 'name', }, }, ]; } protected initFunction(): void { this.dataService.getModels().then((models: any) => { this.regions = models.regionSelectListDsM as RegionSelectList[]; this.roads = models.roadSelectListDsM as RoadSelectList[]; this.roadCategory = models.roadCategorySelectListDsM as RoadCategorySelectList[]; }).then(() => { this.bootstrapGrid(); }); } // tslint:disable-next-line:member-ordering public CreateModel(): Object { return new RoadToCategory(); } }