Fixed creating new filter options in FilterBox (#3584)

This commit is contained in:
Jeff Niu 2017-10-03 22:20:10 -07:00 committed by Maxime Beauchemin
parent 076f9cd095
commit efc63669a6

View File

@ -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);
}
}
}