mirror of
https://github.com/maputnik/editor.git
synced 2026-08-26 15:07:41 +00:00
Define source and layer settings in layout.json
This commit is contained in:
@@ -35,6 +35,7 @@ export default class PropertyGroup extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log(this.props.layer.id, this.props.groupFields)
|
||||||
const fields = this.props.groupFields.map(fieldName => {
|
const fields = this.props.groupFields.map(fieldName => {
|
||||||
const fieldSpec = getFieldSpec(this.props.layer.type, fieldName)
|
const fieldSpec = getFieldSpec(this.props.layer.type, fieldName)
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ export default class LayerEditor extends React.Component {
|
|||||||
layout[this.props.layer.type].groups.forEach(group => {
|
layout[this.props.layer.type].groups.forEach(group => {
|
||||||
editorGroups[group.title] = true
|
editorGroups[group.title] = true
|
||||||
})
|
})
|
||||||
editorGroups['Source'] = true
|
|
||||||
editorGroups['Settings'] = true
|
|
||||||
|
|
||||||
this.state = { editorGroups }
|
this.state = { editorGroups }
|
||||||
}
|
}
|
||||||
@@ -103,32 +101,13 @@ export default class LayerEditor extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
renderGroupType(type, fields) {
|
||||||
console.log('editor groups', this.state.editorGroups)
|
switch(type) {
|
||||||
const layerType = this.props.layer.type
|
case 'settings': return <LayerSettings
|
||||||
const groups = layout[layerType].groups
|
id={this.props.layer.id}
|
||||||
const propertyGroups = groups.map(group => {
|
type={this.props.layer.type}
|
||||||
return <LayerEditorGroup
|
/>
|
||||||
key={group.title}
|
case 'source': return <div>
|
||||||
title={group.title}
|
|
||||||
isActive={this.state.editorGroups[group.title]}
|
|
||||||
onActiveToggle={this.onGroupToggle.bind(this, group.title)}
|
|
||||||
>
|
|
||||||
<PropertyGroup
|
|
||||||
layer={this.props.layer}
|
|
||||||
groupFields={group.fields}
|
|
||||||
onChange={this.onPropertyChange.bind(this)}
|
|
||||||
/>
|
|
||||||
</LayerEditorGroup>
|
|
||||||
})
|
|
||||||
|
|
||||||
let dataGroup = null
|
|
||||||
if(this.props.layer.type !== 'background') {
|
|
||||||
dataGroup = <LayerEditorGroup
|
|
||||||
title="Source"
|
|
||||||
isActive={this.state.editorGroups['Source']}
|
|
||||||
onActiveToggle={this.onGroupToggle.bind(this, 'Source')}
|
|
||||||
>
|
|
||||||
<FilterEditor
|
<FilterEditor
|
||||||
filter={this.props.layer.filter}
|
filter={this.props.layer.filter}
|
||||||
properties={this.props.vectorLayers[this.props.layer['source-layer']]}
|
properties={this.props.vectorLayers[this.props.layer['source-layer']]}
|
||||||
@@ -141,24 +120,34 @@ export default class LayerEditor extends React.Component {
|
|||||||
onSourceChange={console.log}
|
onSourceChange={console.log}
|
||||||
onSourceLayerChange={console.log}
|
onSourceLayerChange={console.log}
|
||||||
/>
|
/>
|
||||||
</LayerEditorGroup>
|
</div>
|
||||||
}
|
case 'properties': return <PropertyGroup
|
||||||
|
layer={this.props.layer}
|
||||||
const settingsGroup = <LayerEditorGroup
|
groupFields={fields}
|
||||||
title="Settings"
|
onChange={this.onPropertyChange.bind(this)}
|
||||||
isActive={this.state.editorGroups['Settings']}
|
|
||||||
onActiveToggle={this.onGroupToggle.bind(this, 'Settings')}
|
|
||||||
>
|
|
||||||
<LayerSettings
|
|
||||||
id={this.props.layer.id}
|
|
||||||
type={this.props.layer.type}
|
|
||||||
/>
|
/>
|
||||||
</LayerEditorGroup>
|
default: return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
console.log('editor groups', this.state.editorGroups)
|
||||||
|
const layerType = this.props.layer.type
|
||||||
|
const layoutGroups = layout[layerType].groups.filter(group => {
|
||||||
|
return !(this.props.layer.type === 'background' && group.type === 'source')
|
||||||
|
}).map(group => {
|
||||||
|
return <LayerEditorGroup
|
||||||
|
key={group.title}
|
||||||
|
title={group.title}
|
||||||
|
isActive={this.state.editorGroups[group.title]}
|
||||||
|
onActiveToggle={this.onGroupToggle.bind(this, group.title)}
|
||||||
|
>
|
||||||
|
{this.renderGroupType(group.type, group.fields)}
|
||||||
|
</LayerEditorGroup>
|
||||||
|
})
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
{settingsGroup}
|
{layoutGroups}
|
||||||
{dataGroup}
|
|
||||||
{propertyGroups}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+46
-6
@@ -1,8 +1,17 @@
|
|||||||
{
|
{
|
||||||
"line": {
|
"line": {
|
||||||
"groups": [
|
"groups": [
|
||||||
|
{
|
||||||
|
"title": "Settings",
|
||||||
|
"type": "settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Source",
|
||||||
|
"type": "source"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Paint",
|
"title": "Paint",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"line-opacity",
|
"line-opacity",
|
||||||
"line-color",
|
"line-color",
|
||||||
@@ -14,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Secondary",
|
"title": "Secondary",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"line-translate",
|
"line-translate",
|
||||||
"line-translate-anchor",
|
"line-translate-anchor",
|
||||||
@@ -30,7 +40,16 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
"title": "primary",
|
"title": "Settings",
|
||||||
|
"type": "settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Source",
|
||||||
|
"type": "source"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Basic",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"background-color",
|
"background-color",
|
||||||
"background-pattern",
|
"background-pattern",
|
||||||
@@ -42,7 +61,16 @@
|
|||||||
"fill": {
|
"fill": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
"title": "primary",
|
"title": "Settings",
|
||||||
|
"type": "settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Source",
|
||||||
|
"type": "source"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Basic",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"fill-opacity",
|
"fill-opacity",
|
||||||
"fill-color",
|
"fill-color",
|
||||||
@@ -58,7 +86,16 @@
|
|||||||
"symbol": {
|
"symbol": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
"title": "primary",
|
"title": "Settings",
|
||||||
|
"type": "settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Source",
|
||||||
|
"type": "source"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Basic",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"text-field",
|
"text-field",
|
||||||
"text-font",
|
"text-font",
|
||||||
@@ -67,7 +104,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "placement",
|
"title": "Placement",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"symbol-placement",
|
"symbol-placement",
|
||||||
"symbol-spacing",
|
"symbol-spacing",
|
||||||
@@ -78,7 +116,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "layout",
|
"title": "Layout",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"text-pitch-alignment",
|
"text-pitch-alignment",
|
||||||
"text-rotation-alignment",
|
"text-rotation-alignment",
|
||||||
@@ -95,7 +134,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "icon",
|
"title": "Icon",
|
||||||
|
"type": "properties",
|
||||||
"fields": [
|
"fields": [
|
||||||
"icon-allow-overlap",
|
"icon-allow-overlap",
|
||||||
"icon-ignore-placement",
|
"icon-ignore-placement",
|
||||||
|
|||||||
Reference in New Issue
Block a user