From fed530f5f29ab2213f84fbe58c5c6759e5a3ace8 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 9 Jan 2017 17:47:35 +0100 Subject: [PATCH] Filter out combining operator select --- .../filter/CombiningOperatorSelect.jsx | 41 +++++++++ src/components/filter/FilterEditor.jsx | 85 +++++++------------ src/components/inputs/MultiButtonInput.jsx | 16 +++- src/components/inputs/SelectInput.jsx | 9 +- 4 files changed, 87 insertions(+), 64 deletions(-) create mode 100644 src/components/filter/CombiningOperatorSelect.jsx diff --git a/src/components/filter/CombiningOperatorSelect.jsx b/src/components/filter/CombiningOperatorSelect.jsx new file mode 100644 index 0000000..7227be4 --- /dev/null +++ b/src/components/filter/CombiningOperatorSelect.jsx @@ -0,0 +1,41 @@ +import React from 'react' +import SelectInput from '../inputs/SelectInput' + +import input from '../../config/input.js' +import { margins } from '../../config/scales.js' + +class CombiningOperatorSelect extends React.Component { + static propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, + style: React.PropTypes.object, + } + + render() { + return
+ + +
+ } +} + +export default CombiningOperatorSelect diff --git a/src/components/filter/FilterEditor.jsx b/src/components/filter/FilterEditor.jsx index d7de3b5..05e74b6 100644 --- a/src/components/filter/FilterEditor.jsx +++ b/src/components/filter/FilterEditor.jsx @@ -3,11 +3,13 @@ import GlSpec from 'mapbox-gl-style-spec/reference/latest.js' import input from '../../config/input.js' import colors from '../../config/colors.js' -import { margins } from '../../config/scales.js' +import { margins, fontSizes } from '../../config/scales.js' +import CombiningOperatorSelect from './CombiningOperatorSelect' import DocLabel from '../fields/DocLabel' import Button from '../Button' import SelectInput from '../inputs/SelectInput' +import MultiButtonInput from '../inputs/MultiButtonInput' import StringInput from '../inputs/StringInput' import AutocompleteInput from '../inputs/AutocompleteInput' @@ -32,45 +34,6 @@ function hasNestedCombiningFilter(filter) { return false } -class CombiningOperatorSelect extends React.Component { - static propTypes = { - value: React.PropTypes.string.isRequired, - onChange: React.PropTypes.func.isRequired, - style: React.PropTypes.object, - } - - render() { - const options = combiningFilterOps.map(op => { - return - }) - - return
- - -
- } -} class OperatorSelect extends React.Component { static propTypes = { @@ -194,16 +157,18 @@ export default class CombiningFilterEditor extends React.Component { const filterEditors = filters.map((f, idx) => { return
- +
+ +
- +
+ +
+ +
+
- {filterEditors}
} diff --git a/src/components/inputs/MultiButtonInput.jsx b/src/components/inputs/MultiButtonInput.jsx index ef78015..a8eab9e 100644 --- a/src/components/inputs/MultiButtonInput.jsx +++ b/src/components/inputs/MultiButtonInput.jsx @@ -15,21 +15,29 @@ class MultiButtonInput extends React.Component { } render() { - const selectedValue = this.props.value || this.props.options[0][0] - const buttons = this.props.options.map(([val, label])=> { + let options = this.props.options + if(options.length > 0 && !Array.isArray(options[0])) { + options = options.map(v => [v, v]) + } + + const selectedValue = this.props.value || options[0][0] + const buttons = options.map(([val, label])=> { return }) - return
+ return
{buttons}
} diff --git a/src/components/inputs/SelectInput.jsx b/src/components/inputs/SelectInput.jsx index ba07ef2..8c3f0b9 100644 --- a/src/components/inputs/SelectInput.jsx +++ b/src/components/inputs/SelectInput.jsx @@ -11,9 +11,10 @@ class SelectInput extends React.Component { render() { - const options = this.props.options.map(([val, label])=> { - return - }) + let options = this.props.options + if(options.length > 0 && !Array.isArray(options[0])) { + options = options.map(v => [v, v]) + } return } }