Blame view

src/app/data/road-to-category/road-to-category.component.ts 2.92 KB
4cfbf7ca   Administrator   add road-to-category
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  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();
    }
  }