diff --git a/src/components/fields/PropertyGroup.jsx b/src/components/fields/PropertyGroup.jsx index 16892ef1..d620351f 100644 --- a/src/components/fields/PropertyGroup.jsx +++ b/src/components/fields/PropertyGroup.jsx @@ -9,12 +9,17 @@ import { margins } from '../../config/scales' /** Extract field spec by {@fieldName} from the {@layerType} in the * style specification from either the paint or layout group */ function getFieldSpec(layerType, fieldName) { + const groupName = getGroupName(layerType, fieldName) + const group = GlSpec[groupName + '_' + layerType] + return group[fieldName] +} + +function getGroupName(layerType, fieldName) { const paint = GlSpec['paint_' + layerType] || {} - const layout = GlSpec['layout_' + layerType] || {} if (fieldName in paint) { - return paint[fieldName] + return 'paint' } else { - return layout[fieldName] + return 'layout' } } @@ -25,12 +30,17 @@ export default class PropertyGroup extends React.Component { onChange: React.PropTypes.func.isRequired, } + onPropertyChange(property, newValue) { + const group = getGroupName(this.props.layer.get('type'), property) + this.props.onChange(group , property ,newValue) + } + render() { const fields = this.props.groupFields.map(fieldName => { const fieldSpec = getFieldSpec(this.props.layer.get('type'), fieldName) const fieldValue = this.props.layer.getIn(['paint', fieldName], this.props.layer.getIn(['layout', fieldName])) return this.props.onChange(this.props.fieldName, newValue) + } switch(this.props.fieldSpec.type) { case 'number': return ( ) case 'enum': return ( ) case 'string': return ( ) case 'color': return ( ) case 'boolean': return ( ) default: return null diff --git a/src/components/filter/FilterEditor.jsx b/src/components/filter/FilterEditor.jsx index 9a139b64..ededcf06 100644 --- a/src/components/filter/FilterEditor.jsx +++ b/src/components/filter/FilterEditor.jsx @@ -75,7 +75,11 @@ class SingleFilterEditor extends React.Component { static propTypes = { filter: React.PropTypes.array.isRequired, onChange: React.PropTypes.func.isRequired, - properties: React.PropTypes.instanceOf(Immutable.Map).isRequired, + properties: React.PropTypes.instanceOf(Immutable.Map), + } + + static defaultProps = { + properties: Immutable.Map(), } onFilterPartChanged(filterOp, propertyName, filterArgs) { diff --git a/src/components/layers/LayerEditor.jsx b/src/components/layers/LayerEditor.jsx index 2b14778d..971e6230 100644 --- a/src/components/layers/LayerEditor.jsx +++ b/src/components/layers/LayerEditor.jsx @@ -61,6 +61,7 @@ export default class LayerEditor extends React.Component { onPropertyChange(group, property, newValue) { const layer = this.props.layer + console.log(group, property, newValue) const changedLayer = layer.setIn([group, property], newValue) this.props.onLayerChanged(changedLayer) }