2016-12-16 16:52:16 +01:00
|
|
|
import React from 'react'
|
|
|
|
|
2016-12-21 14:36:09 +01:00
|
|
|
import InputBlock from '../inputs/InputBlock'
|
|
|
|
import StringInput from '../inputs/StringInput'
|
|
|
|
import SelectInput from '../inputs/SelectInput'
|
|
|
|
import Modal from './Modal'
|
|
|
|
import colors from '../../config/colors'
|
2016-12-16 16:52:16 +01:00
|
|
|
|
|
|
|
class SettingsModal extends React.Component {
|
|
|
|
static propTypes = {
|
2016-12-20 16:08:49 +01:00
|
|
|
mapStyle: React.PropTypes.object.isRequired,
|
2016-12-16 16:52:16 +01:00
|
|
|
onStyleChanged: React.PropTypes.func.isRequired,
|
2016-12-21 16:11:08 +01:00
|
|
|
isOpen: React.PropTypes.bool.isRequired,
|
2016-12-22 16:35:31 +01:00
|
|
|
onOpenToggle: React.PropTypes.func.isRequired,
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
onChange(property, e) {
|
|
|
|
const changedStyle = this.props.mapStyle.set(property, e.target.value)
|
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-12-16 17:13:05 +01:00
|
|
|
onRendererChange(e) {
|
|
|
|
const changedStyle = this.props.mapStyle.setIn(['metadata', 'maputnik:renderer'], e.target.value)
|
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-12-16 16:52:16 +01:00
|
|
|
render() {
|
2016-12-21 16:50:34 +01:00
|
|
|
const inputProps = { }
|
2016-12-21 14:36:09 +01:00
|
|
|
return <Modal
|
2016-12-21 16:11:08 +01:00
|
|
|
isOpen={this.props.isOpen}
|
2016-12-22 16:35:31 +01:00
|
|
|
onOpenToggle={this.props.onOpenToggle}
|
2016-12-21 14:36:09 +01:00
|
|
|
title={'StyleSettings'}
|
|
|
|
>
|
|
|
|
<InputBlock label={"Name"}>
|
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.name}
|
2016-12-16 16:52:16 +01:00
|
|
|
onChange={this.onChange.bind(this, "name")}
|
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
<InputBlock label={"Owner"}>
|
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.owner}
|
2016-12-16 16:52:16 +01:00
|
|
|
onChange={this.onChange.bind(this, "owner")}
|
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
<InputBlock label={"Sprite URL"}>
|
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.sprite}
|
2016-12-16 16:52:16 +01:00
|
|
|
onChange={this.onChange.bind(this, "sprite")}
|
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
|
|
|
|
<InputBlock label={"Glyphs URL"}>
|
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.glyphs}
|
2016-12-16 17:13:05 +01:00
|
|
|
onChange={this.onChange.bind(this, "glyphs")}
|
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
|
|
|
|
|
|
|
|
<InputBlock label={"Style Renderer"}>
|
|
|
|
<SelectInput {...inputProps}
|
|
|
|
options={[
|
|
|
|
['mbgljs', 'MapboxGL JS'],
|
|
|
|
['ol3', 'Open Layers 3']
|
|
|
|
]}
|
2016-12-22 16:54:13 +01:00
|
|
|
value={(this.props.mapStyle.metadata || {})['maputnik:renderer'] || 'mbgljs'}
|
2016-12-16 17:13:05 +01:00
|
|
|
onChange={this.onRendererChange.bind(this)}
|
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
</Modal>
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsModal
|