diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts index 7d595a7..50377f6 100644 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ b/projects/common-map/src/fm-map/actions/map.actions.ts @@ -5,7 +5,7 @@ import { IItemLayer } from '../models/item.layer'; import { ILayervalue } from '../models/layer.value'; import { IQueryState } from '@farmmaps/common'; import { IItem } from '@farmmaps/common'; -import { Feature, Observable } from 'ol'; +import { Feature } from 'ol'; import { Style } from 'ol/style'; import { Geometry } from 'ol/geom'; import { IPeriodState } from '../models/period.state'; @@ -56,7 +56,7 @@ export const GETLAYERVALUE = '[Map] GetLayerValue' export const GETLAYERVALUESUCCESS = '[Map] GetLayerValueSuccess' export const TOGGLESHOWDATALAYERSLIDE = '[Map] ToggleShowDataLayerSlide' export const SETVIEWSTATE = '[Map] SetViewState' -export const SETCODELIST = '[Map] SetCodeList' + export class Clear implements Action { readonly type = CLEAR; @@ -329,12 +329,6 @@ export class SetViewState implements Action { constructor(public enabled:boolean) {} } -export class SetCodeList implements Action { - readonly type = SETCODELIST; - - constructor(public itemType:string, public values: IItem[]) { } -} - export type Actions = SetMapState | Init | Clear @@ -380,6 +374,5 @@ export type Actions = SetMapState | GetLayerValue | SetPeriod | ToggleShowDataLayerSlide - | SetViewState - | SetCodeList; + | SetViewState; diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts index 74552f8..380be41 100644 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ b/projects/common-map/src/fm-map/components/map/map.component.ts @@ -36,7 +36,6 @@ import {Extent,createEmpty,extend } from 'ol/extent'; import {transform} from 'ol/proj'; import { tassign } from 'tassign'; import * as style from 'ol/style'; -import { ICodeLists } from '../../models/codelist.cache'; @Component({ @@ -86,8 +85,6 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit { public overlayLayersCollapsed = true; public extent$: Observable = this.store.select(mapReducers.selectGetExtent); public styles$:Observable = this.store.select(mapReducers.selectGetStyles); - public codeLists$: Observable = this.store.select(mapReducers.selectGetCodeLists); - public codeList$ = (id: string) => this.store.select(mapReducers.selectGetCodeList(id)); public fullscreen$: Observable = this.store.select(commonReducers.selectGetFullScreen); private lastUrl = ""; private initialized = false; diff --git a/projects/common-map/src/fm-map/effects/map.effects.ts b/projects/common-map/src/fm-map/effects/map.effects.ts index 4c525ad..a411723 100644 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ b/projects/common-map/src/fm-map/effects/map.effects.ts @@ -5,7 +5,7 @@ import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store'; import * as fromRouter from '@ngrx/router-store'; import { createEffect, Actions, ofType } from '@ngrx/effects'; -import { EMPTY, Observable, of, forkJoin } from 'rxjs'; +import { EMPTY, Observable, of } from 'rxjs'; import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators'; import { GeoJSON, WKT } from 'ol/format'; @@ -99,65 +99,6 @@ export class MapEffects { color: 'rgba(0, 0, 0, 0)' }) }))); - // cache code lists - forkJoin([ - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl017'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl018'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl020'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl022'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl104'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl127'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl232'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl251'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl256'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl259'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl263'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl264'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl290'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl291'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl293'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl405'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl411'), - this.itemService$.getItemList('vnd.farmmaps.itemtype.codelist.cl421'), - ]).subscribe(([ - cl017, - cl018, - cl020, - cl022, - cl104, - cl127, - cl232, - cl251, - cl256, - cl259, - cl263, - cl264, - cl290, - cl291, - cl293, - cl405, - cl411, - cl421, - ]) => { - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl017', cl017)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl018', cl018)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl020', cl020)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl020', cl020)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl104', cl104)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl127', cl127)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl232', cl232)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl251', cl251)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl256', cl256)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl259', cl259)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl263', cl263)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl264', cl264)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl290', cl290)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl291', cl291)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl293', cl293)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl405', cl405)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl411', cl411)); - actions.push(new mapActions.SetCodeList('vnd.farmmaps.itemtype.codelist.cl421', cl421)); - }); return actions; } diff --git a/projects/common-map/src/fm-map/models/codelist.cache.ts b/projects/common-map/src/fm-map/models/codelist.cache.ts deleted file mode 100644 index 11b223e..0000000 --- a/projects/common-map/src/fm-map/models/codelist.cache.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { IItem } from '@farmmaps/common'; - -export interface ICodeLists { - [id: string]: IItem[]; -} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/reducers/map.reducer.ts b/projects/common-map/src/fm-map/reducers/map.reducer.ts index 843a3be..b70ca44 100644 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ b/projects/common-map/src/fm-map/reducers/map.reducer.ts @@ -1,5 +1,5 @@ import { tassign } from 'tassign'; -import { IItem } from '@farmmaps/common'; +import { IItem,Item } from '@farmmaps/common'; import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer'; import { IMapState} from '../models/map.state'; import { IQueryState} from '@farmmaps/common'; @@ -17,7 +17,6 @@ import {Geometry} from 'ol/geom'; import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store'; import { MODULE_NAME } from '../module-name'; -import { ICodeLists } from '../models/codelist.cache'; const startDate:Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1); const endDate:Date = new Date(Date.now()); @@ -73,8 +72,7 @@ export interface State { layerValuesEnabled:boolean, layerValues: Array showDataLayerSlide:boolean, - viewEnabled: boolean, - codeLists:ICodeLists, + viewEnabled:boolean } export const initialState: State = { @@ -119,8 +117,7 @@ export const initialState: State = { layerValuesEnabled:false, layerValues:[], showDataLayerSlide:false, - viewEnabled: true, - codeLists: {} + viewEnabled:true } export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State { @@ -572,12 +569,6 @@ export function reducer(state = initialState, action: mapActions.Actions | commo } return state; } - case mapActions.SETCODELIST:{ - const a = action as mapActions.SetCodeList; - const codeLists = tassign(state.codeLists); - codeLists[a.itemType] = a.values; - return tassign(state,{codeLists:codeLists}); - } default: { return state; } @@ -616,7 +607,7 @@ export const getLayerValues = (state:State) => state.layerValues; export const getLayerValuesX = (state:State) => state.layerValuesX; export const getLayerValuesY = (state:State) => state.layerValuesY; export const getViewEnabled = (state:State) => state.viewEnabled; -export const getCodeLists = (state:State) => state.codeLists; + export const selectMapState = createFeatureSelector(MODULE_NAME); export const selectGetMapState= createSelector(selectMapState, getMapState); @@ -651,5 +642,5 @@ export const selectGetLayerValues = createSelector(selectMapState,getLayerValues export const selectGetLayerValuesX = createSelector(selectMapState,getLayerValuesX); export const selectGetLayerValuesY = createSelector(selectMapState,getLayerValuesY); export const selectGetViewEnabled = createSelector(selectMapState,getViewEnabled); -export const selectGetCodeLists = createSelector(selectMapState, getCodeLists); -export const selectGetCodeList = (id: string) => createSelector(selectGetCodeLists, (codeLists) => codeLists[id]); \ No newline at end of file + +