mirror of
https://github.com/maputnik/editor.git
synced 2026-07-28 00:37:27 +00:00
Always have default value if value not set
This commit is contained in:
@@ -46,7 +46,7 @@ export default class PropertyGroup extends React.Component {
|
|||||||
onChange={this.onPropertyChange.bind(this)}
|
onChange={this.onPropertyChange.bind(this)}
|
||||||
key={fieldName}
|
key={fieldName}
|
||||||
fieldName={fieldName}
|
fieldName={fieldName}
|
||||||
value={fieldValue}
|
value={fieldValue === undefined ? fieldSpec.default : fieldValue}
|
||||||
fieldSpec={fieldSpec}
|
fieldSpec={fieldSpec}
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ export default class SpecField extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const commonProps = {
|
const commonProps = {
|
||||||
style: this.props.style,
|
style: this.props.style,
|
||||||
default: this.props.fieldSpec.default,
|
|
||||||
value: this.props.value,
|
value: this.props.value,
|
||||||
|
default: this.props.fieldSpec.default,
|
||||||
name: this.props.fieldName,
|
name: this.props.fieldName,
|
||||||
onChange: newValue => this.props.onChange(this.props.fieldName, newValue)
|
onChange: newValue => this.props.onChange(this.props.fieldName, newValue)
|
||||||
}
|
}
|
||||||
@@ -70,13 +70,11 @@ export default class SpecField extends React.Component {
|
|||||||
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
|
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
|
||||||
return <MultiButtonInput
|
return <MultiButtonInput
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
value={this.props.value || this.props.fieldSpec.default}
|
|
||||||
options={options}
|
options={options}
|
||||||
/>
|
/>
|
||||||
} else {
|
} else {
|
||||||
return <SelectInput
|
return <SelectInput
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
value={this.props.value || this.props.fieldSpec.default}
|
|
||||||
options={options}
|
options={options}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { margins } from '../../config/scales'
|
|||||||
|
|
||||||
class CheckboxInput extends React.Component {
|
class CheckboxInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.bool.isRequired,
|
||||||
style: React.PropTypes.object,
|
style: React.PropTypes.object,
|
||||||
onChange: React.PropTypes.func,
|
onChange: React.PropTypes.func,
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ class CheckboxInput extends React.Component {
|
|||||||
...styles.input,
|
...styles.input,
|
||||||
...this.props.style,
|
...this.props.style,
|
||||||
}}
|
}}
|
||||||
onChange={e => {this.props.onChange(!this.props.value)}}
|
onChange={e => this.props.onChange(!this.props.value)}
|
||||||
checked={this.props.value}
|
checked={this.props.value}
|
||||||
/>
|
/>
|
||||||
<div style={styles.box}>
|
<div style={styles.box}>
|
||||||
|
|||||||
Reference in New Issue
Block a user