Skip to content

Commit

Permalink
Fixed creating new filter options in FilterBox (apache#3584)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogball authored and michellethomas committed May 23, 2018
1 parent 2784e10 commit a36ff5e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions superset/assets/visualizations/filter_box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ class FilterBox extends React.Component {
}
// Add created options to filtersChoices, even though it doesn't exist,
// or these options will exist in query sql but invisible to end user.
if (this.state.selectedValues.hasOwnProperty()) {
for (const filterKey of this.state.selectedValues) {
const existValues = this.props.filtersChoices[filterKey].map(f => f.id);
for (const v of this.state.selectedValues[filterKey]) {
if (existValues.indexOf(v) === -1) {
const addChoice = {
filter: filterKey,
id: v,
text: v,
metric: 0,
};
this.props.filtersChoices[filterKey].push(addChoice);
}
for (const filterKey in this.state.selectedValues) {
if (!this.state.selectedValues.hasOwnProperty(filterKey)) {
continue;
}
const existValues = this.props.filtersChoices[filterKey].map(f => f.id);
for (const v of this.state.selectedValues[filterKey]) {
if (existValues.indexOf(v) === -1) {
const addChoice = {
filter: filterKey,
id: v,
text: v,
metric: 0,
};
this.props.filtersChoices[filterKey].push(addChoice);
}
}
}
Expand Down

0 comments on commit a36ff5e

Please sign in to comment.