Fix setting style properties in settings modal

This commit is contained in:
Lukas Martinelli 2016-12-29 17:32:23 +01:00
parent d16c3f4356
commit a5307054b3

View file

@ -18,17 +18,20 @@ class SettingsModal extends React.Component {
super(props); super(props);
} }
onChange(property, e) { changeStyleProperty(property, value) {
const changedStyle = this.props.mapStyle.set(property, e.target.value) const changedStyle = {
...this.props.mapStyle,
[property]: value
}
this.props.onStyleChanged(changedStyle) this.props.onStyleChanged(changedStyle)
} }
onMetadataChange(key, value) { changeMetadataProperty(property, value) {
const changedStyle = { const changedStyle = {
...this.props.mapStyle, ...this.props.mapStyle,
metadata: { metadata: {
...this.props.mapStyle.metadata, ...this.props.mapStyle.metadata,
[key]: value [property]: value
} }
} }
this.props.onStyleChanged(changedStyle) this.props.onStyleChanged(changedStyle)
@ -45,33 +48,33 @@ class SettingsModal extends React.Component {
<InputBlock label={"Name"}> <InputBlock label={"Name"}>
<StringInput {...inputProps} <StringInput {...inputProps}
value={this.props.mapStyle.name} value={this.props.mapStyle.name}
onChange={this.onChange.bind(this, "name")} onChange={this.changeStyleProperty.bind(this, "name")}
/> />
</InputBlock> </InputBlock>
<InputBlock label={"Owner"}> <InputBlock label={"Owner"}>
<StringInput {...inputProps} <StringInput {...inputProps}
value={this.props.mapStyle.owner} value={this.props.mapStyle.owner}
onChange={this.onChange.bind(this, "owner")} onChange={this.changeStyleProperty.bind(this, "owner")}
/> />
</InputBlock> </InputBlock>
<InputBlock label={"Sprite URL"}> <InputBlock label={"Sprite URL"}>
<StringInput {...inputProps} <StringInput {...inputProps}
value={this.props.mapStyle.sprite} value={this.props.mapStyle.sprite}
onChange={this.onChange.bind(this, "sprite")} onChange={this.changeStyleProperty.bind(this, "sprite")}
/> />
</InputBlock> </InputBlock>
<InputBlock label={"Glyphs URL"}> <InputBlock label={"Glyphs URL"}>
<StringInput {...inputProps} <StringInput {...inputProps}
value={this.props.mapStyle.glyphs} value={this.props.mapStyle.glyphs}
onChange={this.onChange.bind(this, "glyphs")} onChange={this.changeStyleProperty.bind(this, "glyphs")}
/> />
</InputBlock> </InputBlock>
<InputBlock label={"Access Token"}> <InputBlock label={"Access Token"}>
<StringInput {...inputProps} <StringInput {...inputProps}
value={metadata['maputnik:access_token']} value={metadata['maputnik:access_token']}
onChange={this.onMetadataChange.bind(this, "maputnik:access_token")} onChange={this.changeMetadataProperty.bind(this, "maputnik:access_token")}
/> />
</InputBlock> </InputBlock>
@ -83,7 +86,7 @@ class SettingsModal extends React.Component {
['inspection', 'Inspection Mode'], ['inspection', 'Inspection Mode'],
]} ]}
value={metadata['maputnik:renderer'] || 'mbgljs'} value={metadata['maputnik:renderer'] || 'mbgljs'}
onChange={this.onMetadataChange.bind(this, 'maputnik:renderer')} onChange={this.changeMetadataProperty.bind(this, 'maputnik:renderer')}
/> />
</InputBlock> </InputBlock>
</Modal> </Modal>