Mercurial > gemma
comparison client/src/map/store.js @ 975:3da707172772
refac: removed technical debt
Cleaned up mapstore to adhere more to
Single Repsonsibility Principle (SRP)
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 18 Oct 2018 16:47:17 +0200 |
parents | 2025074ad835 |
children | ca628dce90dd |
comparison
equal
deleted
inserted
replaced
974:7a89313f0ead | 975:3da707172772 |
---|---|
4 | 4 |
5 const MapStore = { | 5 const MapStore = { |
6 namespaced: true, | 6 namespaced: true, |
7 state: { | 7 state: { |
8 openLayersMap: null, | 8 openLayersMap: null, |
9 layers: layers, | 9 layers: layers |
10 // note that some identified features may not have an id | |
11 // especially related to drawing in our own vector layer | |
12 identifiedFeatures: [], | |
13 currentMeasurement: null, | |
14 selectedMorph: null | |
15 }, | 10 }, |
16 getters: { | 11 getters: { |
17 layers: state => { | 12 layers: state => { |
18 return state.layers; | 13 return state.layers; |
19 }, | 14 }, |
24 mutations: { | 19 mutations: { |
25 toggleVisibility: (state, layer) => { | 20 toggleVisibility: (state, layer) => { |
26 state.layers[layer].isVisible = !state.layers[layer].isVisible; | 21 state.layers[layer].isVisible = !state.layers[layer].isVisible; |
27 state.layers[layer].data.setVisible(state.layers[layer].isVisible); | 22 state.layers[layer].data.setVisible(state.layers[layer].isVisible); |
28 }, | 23 }, |
29 setIdentifiedFeatures: (state, identifiedFeatures) => { | |
30 state.identifiedFeatures = identifiedFeatures; | |
31 }, | |
32 setOpenLayersMap: (state, map) => { | 24 setOpenLayersMap: (state, map) => { |
33 state.openLayersMap = map; | 25 state.openLayersMap = map; |
34 }, | |
35 setCurrentMeasurement: (state, measurement) => { | |
36 state.currentMeasurement = measurement; | |
37 }, | |
38 setSelectedMorph: (state, selectedMorph) => { | |
39 state.selectedMorph = selectedMorph; | |
40 } | 26 } |
41 } | 27 } |
42 }; | 28 }; |
43 | 29 |
44 export default MapStore; | 30 export default MapStore; |