mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Enable freeform-select with fetched column values for filter values (#1697)
* Enable freeform-select with fetched column values for filter values - db migration to add filter_select_enabled - add freeform-multi option for Selectfield - modify formatFilter() function on query to accomodate filter-select * Fix js tests * Fix codeclimate issue * Changes based on comments * Add test for filter endpoint * Extract out renderFilterFormField function from render * Fix landscape issues
This commit is contained in:
@@ -58,8 +58,18 @@ export default class SelectField extends React.Component {
|
||||
if (this.props.freeForm) {
|
||||
// For FreeFormSelect, insert value into options if not exist
|
||||
const values = choices.map((c) => c[0]);
|
||||
if (values.indexOf(this.props.value) === -1) {
|
||||
options.push({ value: this.props.value, label: this.props.value });
|
||||
if (this.props.value) {
|
||||
if (typeof this.props.value === 'object') {
|
||||
this.props.value.forEach((v) => {
|
||||
if (values.indexOf(v) === -1) {
|
||||
options.push({ value: v, label: v });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (values.indexOf(this.props.value) === -1) {
|
||||
options.push({ value: this.props.value, label: this.props.value });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,13 +87,19 @@ export default class SelectField extends React.Component {
|
||||
// Tab, comma or Enter will trigger a new option created for FreeFormSelect
|
||||
const selectWrap = this.props.freeForm ?
|
||||
(<Creatable {...selectProps} />) : (<Select {...selectProps} />);
|
||||
|
||||
if (this.props.label) {
|
||||
return (
|
||||
<div id={`formControlsSelect-${slugify(this.props.label)}`}>
|
||||
<ControlLabelWithTooltip
|
||||
label={this.props.label}
|
||||
description={this.props.description}
|
||||
/>
|
||||
{selectWrap}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div id={`formControlsSelect-${slugify(this.props.label)}`}>
|
||||
<ControlLabelWithTooltip
|
||||
label={this.props.label}
|
||||
description={this.props.description}
|
||||
/>
|
||||
<div>
|
||||
{selectWrap}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user