mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:41:17 +01:00
Add filter editor block
This commit is contained in:
parent
7e8813f417
commit
153232c143
2 changed files with 41 additions and 14 deletions
|
@ -9,6 +9,7 @@ import { combiningFilterOps } from '../../libs/filterops.js'
|
||||||
import OperatorSelect from './OperatorSelect'
|
import OperatorSelect from './OperatorSelect'
|
||||||
import SingleFilterEditor from './SingleFilterEditor'
|
import SingleFilterEditor from './SingleFilterEditor'
|
||||||
import CombiningOperatorSelect from './CombiningOperatorSelect'
|
import CombiningOperatorSelect from './CombiningOperatorSelect'
|
||||||
|
import FilterEditorBlock from './FilterEditorBlock'
|
||||||
import DocLabel from '../fields/DocLabel'
|
import DocLabel from '../fields/DocLabel'
|
||||||
import Button from '../Button'
|
import Button from '../Button'
|
||||||
|
|
||||||
|
@ -75,26 +76,14 @@ export default class CombiningFilterEditor extends React.Component {
|
||||||
let filters = filter.slice(1)
|
let filters = filter.slice(1)
|
||||||
|
|
||||||
const filterEditors = filters.map((f, idx) => {
|
const filterEditors = filters.map((f, idx) => {
|
||||||
return <div>
|
return <FilterEditorBlock onDelete={this.deleteFilterItem.bind(this, idx)}>
|
||||||
<div style={{display: 'inline-block', width: '25%'}}>
|
|
||||||
<Button
|
|
||||||
style={{backgroundColor: null}}
|
|
||||||
onClick={this.deleteFilterItem.bind(this, idx)}
|
|
||||||
>
|
|
||||||
<DeleteIcon />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<SingleFilterEditor
|
<SingleFilterEditor
|
||||||
style={{
|
|
||||||
display: 'inline-block',
|
|
||||||
width: '75%'
|
|
||||||
}}
|
|
||||||
key={idx}
|
key={idx}
|
||||||
properties={this.props.properties}
|
properties={this.props.properties}
|
||||||
filter={f}
|
filter={f}
|
||||||
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
|
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</FilterEditorBlock>
|
||||||
})
|
})
|
||||||
|
|
||||||
//TODO: Implement support for nested filter
|
//TODO: Implement support for nested filter
|
||||||
|
|
38
src/components/filter/FilterEditorBlock.jsx
Normal file
38
src/components/filter/FilterEditorBlock.jsx
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import React from 'react'
|
||||||
|
import Button from '../Button'
|
||||||
|
import DeleteIcon from 'react-icons/lib/md/delete'
|
||||||
|
|
||||||
|
class FilterEditorBlock extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
onDelete: React.PropTypes.func.isRequired,
|
||||||
|
children: React.PropTypes.element.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
renderChildren() {
|
||||||
|
return React.Children.map(this.props.children, child => {
|
||||||
|
return React.cloneElement(child, {
|
||||||
|
style: {
|
||||||
|
...child.props.style,
|
||||||
|
display: 'inline-block',
|
||||||
|
width: '75%',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <div>
|
||||||
|
<div style={{display: 'inline-block', width: '25%'}}>
|
||||||
|
<Button
|
||||||
|
style={{backgroundColor: null}}
|
||||||
|
onClick={this.props.onDelete}
|
||||||
|
>
|
||||||
|
<DeleteIcon />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{this.props.children}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FilterEditorBlock
|
Loading…
Reference in a new issue