Commit 076bf122ece39313614aef837265edf26b81db24
1 parent
919f866f
Styles
Showing
5 changed files
with
96 additions
and
10 deletions
Show diff stats
src/app/app.module.ts
| @@ -6,7 +6,7 @@ import { RouterModule } from '@angular/router'; | @@ -6,7 +6,7 @@ import { RouterModule } from '@angular/router'; | ||
| 6 | import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularclass/hmr'; | 6 | import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularclass/hmr'; |
| 7 | 7 | ||
| 8 | // Services | 8 | // Services |
| 9 | -import { RegionSelectListService } from './services/regionselectlist.service'; | 9 | +import { BusStopCreateService } from './services/busstopcreate.service'; |
| 10 | 10 | ||
| 11 | /* | 11 | /* |
| 12 | * Platform and Environment providers/directives/pipes | 12 | * Platform and Environment providers/directives/pipes |
| @@ -54,7 +54,7 @@ export type StoreType = { | @@ -54,7 +54,7 @@ export type StoreType = { | ||
| 54 | providers: [ // expose our Services and Providers into Angular's dependency injection | 54 | providers: [ // expose our Services and Providers into Angular's dependency injection |
| 55 | ENV_PROVIDERS, | 55 | ENV_PROVIDERS, |
| 56 | APP_PROVIDERS, | 56 | APP_PROVIDERS, |
| 57 | - RegionSelectListService | 57 | + BusStopCreateService |
| 58 | ] | 58 | ] |
| 59 | }) | 59 | }) |
| 60 | 60 |
src/app/pages/statements/components/busStop2/busStop2.component.ts
| @@ -4,8 +4,12 @@ import { BusStop2Service } from './busStop2.service'; | @@ -4,8 +4,12 @@ import { BusStop2Service } from './busStop2.service'; | ||
| 4 | import { busStop2 } from './busStop2'; | 4 | import { busStop2 } from './busStop2'; |
| 5 | import { LocalDataSource } from 'ng2-smart-table'; | 5 | import { LocalDataSource } from 'ng2-smart-table'; |
| 6 | import { GridOptions } from 'ag-grid/main'; | 6 | import { GridOptions } from 'ag-grid/main'; |
| 7 | -import { RegionSelectListService } from '../../../../services/regionselectlist.service'; | 7 | +import { BusStopCreateService } from '../../../../services/busstopcreate.service'; |
| 8 | import { RegionSelectList } from '../../../../models/regionselectlist'; | 8 | import { RegionSelectList } from '../../../../models/regionselectlist'; |
| 9 | +import { StateCommonSelectList } from '../../../../models/statecommonselectlist'; | ||
| 10 | +import { RoadSelectList } from '../../../../models/roadselectlist'; | ||
| 11 | +import { SettlementSelectList } from '../../../../models/settlementselectlist'; | ||
| 12 | +import { SurfaceTypeSelectList } from '../../../../models/surfacetypeselectlist'; | ||
| 9 | import { EditorComponent } from '../../../../components/editor.component'; | 13 | import { EditorComponent } from '../../../../components/editor.component'; |
| 10 | import { RendererComponent } from '../../../../components/renderer.component'; | 14 | import { RendererComponent } from '../../../../components/renderer.component'; |
| 11 | 15 | ||
| @@ -24,15 +28,26 @@ export class BusStop2 { | @@ -24,15 +28,26 @@ export class BusStop2 { | ||
| 24 | public rowData: any[]; | 28 | public rowData: any[]; |
| 25 | public rowCount: string; | 29 | public rowCount: string; |
| 26 | public regions: RegionSelectList[]; | 30 | public regions: RegionSelectList[]; |
| 31 | + public states: StateCommonSelectList[]; | ||
| 32 | + public surfaceTypes: SurfaceTypeSelectList[]; | ||
| 33 | + public settlements: SettlementSelectList[]; | ||
| 34 | + public roads: RoadSelectList[]; | ||
| 27 | private gridOptions: GridOptions; | 35 | private gridOptions: GridOptions; |
| 28 | private columnDefs: any[]; | 36 | private columnDefs: any[]; |
| 29 | 37 | ||
| 30 | 38 | ||
| 31 | - constructor(protected service: BusStop2Service, private regionlistservice: RegionSelectListService) { | ||
| 32 | - this.regionlistservice.getModels().then(models => { | ||
| 33 | - this.regions = models; | ||
| 34 | - this.createColumnDefs(); | ||
| 35 | - }); | 39 | + constructor( |
| 40 | + protected service: BusStop2Service, | ||
| 41 | + private dataService: BusStopCreateService, | ||
| 42 | + ) { | ||
| 43 | + this.dataService.getModels().then(models => { | ||
| 44 | + this.regions = models.regionSelectListDsM as RegionSelectList[]; | ||
| 45 | + this.states = models.stateCommonSelectListDsM as StateCommonSelectList[]; | ||
| 46 | + this.surfaceTypes = models.surfaceTypeSelectListDsM as SurfaceTypeSelectList[]; | ||
| 47 | + this.settlements = models.settlementSelectListDsM as SettlementSelectList[]; | ||
| 48 | + this.roads = models.roadSelectListDsM as RoadSelectList[]; | ||
| 49 | + this.createColumnDefs(); | ||
| 50 | + }); | ||
| 36 | this.gridOptions = <GridOptions>{}; | 51 | this.gridOptions = <GridOptions>{}; |
| 37 | // this.gridOptions.rowModelType = 'virtual'; | 52 | // this.gridOptions.rowModelType = 'virtual'; |
| 38 | this.service.getData().then((data) => { | 53 | this.service.getData().then((data) => { |
| @@ -75,7 +90,14 @@ export class BusStop2 { | @@ -75,7 +90,14 @@ export class BusStop2 { | ||
| 75 | headerName: 'Назва дороги', | 90 | headerName: 'Назва дороги', |
| 76 | field: 'roadId', | 91 | field: 'roadId', |
| 77 | editable: true, | 92 | editable: true, |
| 78 | - width: 150 | 93 | + width: 150, |
| 94 | + cellEditorFramework: EditorComponent, | ||
| 95 | + cellRendererFramework: RendererComponent, | ||
| 96 | + cellEditorParams: { | ||
| 97 | + data: this.roads, | ||
| 98 | + valueCol: 'roadId', | ||
| 99 | + labelCol: 'name' | ||
| 100 | + } | ||
| 79 | }, | 101 | }, |
| 80 | { | 102 | { |
| 81 | headerName: 'Область', | 103 | headerName: 'Область', |
| @@ -106,7 +128,14 @@ export class BusStop2 { | @@ -106,7 +128,14 @@ export class BusStop2 { | ||
| 106 | headerName: 'Технічний стан', | 128 | headerName: 'Технічний стан', |
| 107 | field: 'stateCommonId', | 129 | field: 'stateCommonId', |
| 108 | editable: true, | 130 | editable: true, |
| 109 | - width: 150 | 131 | + width: 150, |
| 132 | + cellEditorFramework: EditorComponent, | ||
| 133 | + cellRendererFramework: RendererComponent, | ||
| 134 | + cellEditorParams: { | ||
| 135 | + data: this.states, | ||
| 136 | + valueCol: 'commonStateId', | ||
| 137 | + labelCol: 'value' | ||
| 138 | + } | ||
| 110 | } | 139 | } |
| 111 | ]; | 140 | ]; |
| 112 | } | 141 | } |
src/app/pages/statements/components/busStop2/busStop2.scss
| @@ -57,3 +57,16 @@ nav.ng2-smart-pagination-nav { | @@ -57,3 +57,16 @@ nav.ng2-smart-pagination-nav { | ||
| 57 | display: flex; | 57 | display: flex; |
| 58 | justify-content: center; | 58 | justify-content: center; |
| 59 | } | 59 | } |
| 60 | + | ||
| 61 | +editor-cell div { | ||
| 62 | + background: black; | ||
| 63 | + height: 300px; | ||
| 64 | + overflow-y: auto; | ||
| 65 | + p { | ||
| 66 | + padding: 5px; | ||
| 67 | + cursor: pointer; | ||
| 68 | + &:hover { | ||
| 69 | + color: lightslategray; | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | +} |
| 1 | +import { Injectable } from '@angular/core'; | ||
| 2 | +import { Headers, Http } from '@angular/http'; | ||
| 3 | + | ||
| 4 | +import 'rxjs/add/operator/toPromise'; | ||
| 5 | + | ||
| 6 | +@Injectable() | ||
| 7 | +export class BusStopCreateService { | ||
| 8 | + private apiUrl = 'http://localhost:5000/busstop'; | ||
| 9 | + private headers = new Headers({'Content-Type': 'applicaton/json'}); | ||
| 10 | + constructor(private http: Http) { } | ||
| 11 | + getModels(): Promise<any> { | ||
| 12 | + return this.http.get(this.apiUrl) | ||
| 13 | + .toPromise() | ||
| 14 | + .then(response => response.json()) | ||
| 15 | + .catch(this.handleError); | ||
| 16 | + } | ||
| 17 | + private handleError(error: any): Promise<any> { | ||
| 18 | + console.error('An error occured', error); | ||
| 19 | + return Promise.reject(error.message || error); | ||
| 20 | + } | ||
| 21 | +} |
src/app/services/statecommonselectlist.service.ts
| 1 | +import { Injectable } from '@angular/core'; | ||
| 2 | +import { Headers, Http } from '@angular/http'; | ||
| 3 | + | ||
| 4 | +import 'rxjs/add/operator/toPromise'; | ||
| 5 | + | ||
| 6 | +import { StateCommonSelectList } from '../models/statecommonselectlist'; | ||
| 7 | + | ||
| 8 | +@Injectable() | ||
| 9 | +export class StateCommonSelectListService { | ||
| 10 | + private apiUrl = 'http://localhost:5000/directory/statecommonds'; | ||
| 11 | + private headers = new Headers({'Content-Type': 'applicaton/json'}); | ||
| 12 | + constructor(private http: Http) { } | ||
| 13 | + getModels(): Promise<StateCommonSelectList[]> { | ||
| 14 | + return this.http.get(this.apiUrl) | ||
| 15 | + .toPromise() | ||
| 16 | + .then(response => response.json().stateCommonSelectListDsM as StateCommonSelectList[]) | ||
| 17 | + .catch(this.handleError); | ||
| 18 | + } | ||
| 19 | + private handleError(error: any): Promise<any> { | ||
| 20 | + console.error('An error occured', error); | ||
| 21 | + return Promise.reject(error.message || error); | ||
| 22 | + } | ||
| 23 | +} |