AW-2924 Cache codelists
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
FarmMaps/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
2023-08-07 14:49:04 +02:00
parent b182b7fda6
commit 914e272fc2
5 changed files with 93 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
import { tassign } from 'tassign';
import { IItem,Item } from '@farmmaps/common';
import { IItem } from '@farmmaps/common';
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer';
import { IMapState} from '../models/map.state';
import { IQueryState} from '@farmmaps/common';
@@ -17,6 +17,7 @@ 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());
@@ -72,7 +73,8 @@ export interface State {
layerValuesEnabled:boolean,
layerValues: Array<ILayervalue>
showDataLayerSlide:boolean,
viewEnabled:boolean
viewEnabled: boolean,
codeLists:ICodeLists,
}
export const initialState: State = {
@@ -117,7 +119,8 @@ export const initialState: State = {
layerValuesEnabled:false,
layerValues:[],
showDataLayerSlide:false,
viewEnabled:true
viewEnabled: true,
codeLists: {}
}
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
@@ -569,6 +572,12 @@ 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;
}
@@ -607,7 +616,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<State>(MODULE_NAME);
export const selectGetMapState= createSelector(selectMapState, getMapState);
@@ -642,5 +651,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]);