Repository navigation
Expand file tree
/
Copy pathlayers.js
More file actions
executable file
·72 lines (66 loc) · 1.9 KB
/
Copy pathlayers.js
File metadata and controls
executable file
·72 lines (66 loc) · 1.9 KB
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
import { fromJS } from 'immutable'
import { REHYDRATE } from 'redux-persist'
import { handleActions } from 'redux-actions'
// Constants
// --------------------------------------------------
export const SET_EDIT_LAYER = 'SET_EDIT_LAYER'
export const SET_SELECTION = 'SET_SELECTION'
export const SET_CURRENT_ATTRIBUTE = 'SET_CURRENT_ATTRIBUTE'
export const SET_ANALYST_LAYER = 'SET_ANALYST_LAYER'
// Actions
// --------------------------------------------------
export const setEditLayer = (params, cb = () => {}) => async dispatch => {
await dispatch({
type: SET_EDIT_LAYER,
payload: params || {},
})
cb && cb()
}
export const setSelection = (params, cb = () => {}) => async dispatch => {
await dispatch({
type: SET_SELECTION,
payload: params || {},
})
cb && cb()
}
export const setCurrentAttribute = (params, cb = () => {}) => async dispatch => {
await dispatch({
type: SET_CURRENT_ATTRIBUTE,
payload: params || {},
})
cb && cb()
}
export const setAnalystLayer = (params, cb = () => {}) => async dispatch => {
await dispatch({
type: SET_ANALYST_LAYER,
payload: params || {},
})
cb && cb()
}
const initialState = fromJS({
layers: {},
editLayer: {},
selection: {},
currentAttribute: {},
analystLayer: {},
})
export default handleActions(
{
[`${SET_EDIT_LAYER}`]: (state, { payload }) => {
return state.setIn(['editLayer'], fromJS(payload))
},
[`${SET_SELECTION}`]: (state, { payload }) => {
return state.setIn(['selection'], fromJS(payload))
},
[`${SET_CURRENT_ATTRIBUTE}`]: (state, { payload }) => {
return state.setIn(['currentAttribute'], fromJS(payload))
},
[`${SET_ANALYST_LAYER}`]: (state, { payload }) => {
return state.setIn(['analystLayer'], fromJS(payload))
},
[REHYDRATE]: (state, { payload }) => {
return payload && payload.layers ? fromJS(payload.layers) : state
},
},
initialState,
)