Switch away from Immutable JS for layer editor

This commit is contained in:
Lukas Martinelli
2016-12-20 14:50:38 +01:00
parent 28b61e7dcb
commit ed87425f01
4 changed files with 41 additions and 25 deletions

View File

@@ -1,4 +1,5 @@
import React from 'react'
import Immutable from 'immutable'
import { saveAs } from 'file-saver'
import Drawer from 'rebass/dist/Drawer'
@@ -99,7 +100,7 @@ export default class App extends React.Component {
}
onLayerChanged(layer) {
const changedStyle = this.state.mapStyle.setIn(['layers', layer.get('id')], layer)
const changedStyle = this.state.mapStyle.setIn(['layers', layer.id], Immutable.fromJS(layer))
this.onStyleChanged(changedStyle)
}
@@ -125,6 +126,7 @@ export default class App extends React.Component {
render() {
const selectedLayer = this.state.mapStyle.getIn(['layers', this.state.selectedLayerId], null)
return <div style={{ fontFamily: theme.fontFamily, color: theme.color, fontWeight: 300 }}>
<Toolbar
mapStyle={this.state.mapStyle}
@@ -160,7 +162,7 @@ export default class App extends React.Component {
width: 300,
backgroundColor: colors.gray}
}>
{selectedLayer && <LayerEditor layer={selectedLayer} onLayerChanged={this.onLayerChanged.bind(this)} sources={this.layerWatcher.sources} vectorLayers={this.layerWatcher.vectorLayers}/>}
{selectedLayer && <LayerEditor layer={selectedLayer.toJS()} onLayerChanged={this.onLayerChanged.bind(this)} sources={this.layerWatcher.sources} vectorLayers={this.layerWatcher.vectorLayers}/>}
</div>
{this.mapRenderer()}
</div>