mirror of
https://github.com/maputnik/editor.git
synced 2025-12-25 23:50:02 +00:00
Add filter editor block
This commit is contained in:
@@ -9,6 +9,7 @@ import { combiningFilterOps } from '../../libs/filterops.js'
|
||||
import OperatorSelect from './OperatorSelect'
|
||||
import SingleFilterEditor from './SingleFilterEditor'
|
||||
import CombiningOperatorSelect from './CombiningOperatorSelect'
|
||||
import FilterEditorBlock from './FilterEditorBlock'
|
||||
import DocLabel from '../fields/DocLabel'
|
||||
import Button from '../Button'
|
||||
|
||||
@@ -75,26 +76,14 @@ export default class CombiningFilterEditor extends React.Component {
|
||||
let filters = filter.slice(1)
|
||||
|
||||
const filterEditors = filters.map((f, idx) => {
|
||||
return <div>
|
||||
<div style={{display: 'inline-block', width: '25%'}}>
|
||||
<Button
|
||||
style={{backgroundColor: null}}
|
||||
onClick={this.deleteFilterItem.bind(this, idx)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</div>
|
||||
return <FilterEditorBlock onDelete={this.deleteFilterItem.bind(this, idx)}>
|
||||
<SingleFilterEditor
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
width: '75%'
|
||||
}}
|
||||
key={idx}
|
||||
properties={this.props.properties}
|
||||
filter={f}
|
||||
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
|
||||
/>
|
||||
</div>
|
||||
</FilterEditorBlock>
|
||||
})
|
||||
|
||||
//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
|
||||
Reference in New Issue
Block a user