Add action logging and some refactoring
This commit is contained in:
@@ -56,7 +56,8 @@ export interface State {
|
||||
selectedOverlayLayer: IItemLayer,
|
||||
styles:IStyles,
|
||||
showLayerSwitcher:boolean,
|
||||
setStateCount:number
|
||||
setStateCount:number,
|
||||
inSearch:boolean
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
@@ -73,7 +74,7 @@ export const initialState: State = {
|
||||
},
|
||||
viewExtent:[],
|
||||
queryState: tassign(initialQueryState),
|
||||
query: tassign(initialQueryState),
|
||||
query: null,
|
||||
parentCode: null,
|
||||
features: [],
|
||||
panelVisible: false,
|
||||
@@ -92,7 +93,8 @@ export const initialState: State = {
|
||||
selectedItemLayer: null,
|
||||
styles: {},
|
||||
showLayerSwitcher: false,
|
||||
setStateCount: 0
|
||||
setStateCount: 0,
|
||||
inSearch:false
|
||||
}
|
||||
|
||||
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
||||
@@ -138,7 +140,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
return tassign(state, {
|
||||
features: a.features,
|
||||
extent:extent
|
||||
extent:extent,
|
||||
inSearch:false
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTFEATURE: {
|
||||
@@ -147,11 +150,15 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTITEM: {
|
||||
case mapActions.SELECTITEM: {
|
||||
let a = action as mapActions.SelectItem;
|
||||
let itemCode = state.selectedItem ? state.selectedItem.code : "";
|
||||
let inSearch = (a.itemCode != itemCode || state.setStateCount == 1)
|
||||
return tassign(state, {
|
||||
selectedItem: null,
|
||||
selectedItemLayer: null,
|
||||
features:[]
|
||||
features:[],
|
||||
inSearch:inSearch
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTITEMSUCCESS: {
|
||||
@@ -164,6 +171,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
itemLayer = new TemporalItemLayer(a.item);
|
||||
}
|
||||
return tassign(state, {
|
||||
inSearch:false,
|
||||
selectedItem: a.item,
|
||||
selectedItemLayer: itemLayer,
|
||||
panelVisible: a.item != null,
|
||||
@@ -255,17 +263,21 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
case mapActions.STARTSEARCH: {
|
||||
let a = action as mapActions.StartSearch;
|
||||
let panelVisible = a.queryState.itemCode!=null ||a.queryState.itemType!=null||a.queryState.parentCode!=null;
|
||||
return tassign(state, {
|
||||
selectedItem: null,
|
||||
features:[],
|
||||
selectedItemLayer:null,
|
||||
queryState: tassign(a.queryState),
|
||||
searchCollapsed: false,
|
||||
panelVisible: true,
|
||||
clearEnabled: true,
|
||||
searchMinified: true,
|
||||
searchCollapsed: !panelVisible,
|
||||
panelVisible: panelVisible,
|
||||
clearEnabled: panelVisible,
|
||||
searchMinified: panelVisible,
|
||||
inSearch:panelVisible
|
||||
});
|
||||
}
|
||||
case commonActions.FAIL:{
|
||||
return tassign(state,{inSearch:false});
|
||||
}
|
||||
case mapActions.DOQUERY: {
|
||||
let a = action as mapActions.DoQuery;
|
||||
return tassign(state, {
|
||||
@@ -455,7 +467,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
let a = action as mapActions.ShowLayerSwitcher;
|
||||
return tassign(state,{showLayerSwitcher:a.show});
|
||||
}
|
||||
case mapActions.CLEAR:{
|
||||
|
||||
case commonActions.INITUSER: {
|
||||
return tassign(state,{setStateCount:0,features:[],selectedFeature:null,selectedItem:null});
|
||||
}
|
||||
default: {
|
||||
@@ -487,6 +500,7 @@ export const getPeriod = (state:State) => state.period;
|
||||
export const getStyles = (state:State) => state.styles;
|
||||
export const getShowLayerSwitcher = (state:State) => state.showLayerSwitcher;
|
||||
export const getSetStateCount = (state:State) => state.setStateCount;
|
||||
export const getInSearch = (state:State) => state.inSearch;
|
||||
|
||||
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
|
||||
export const selectGetMapState= createSelector(selectMapState, getMapState);
|
||||
@@ -512,5 +526,6 @@ export const selectGetPeriod = createSelector(selectMapState, getPeriod);
|
||||
export const selectGetStyles = createSelector(selectMapState, getStyles);
|
||||
export const selectGetShowLayerSwitcher = createSelector(selectMapState,getShowLayerSwitcher);
|
||||
export const selectgetSetStateCount = createSelector(selectMapState,getSetStateCount);
|
||||
export const selectGetInSearch = createSelector(selectMapState,getInSearch);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user