mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
minor filter select enhancements (#3933)
* `values_for_column` configurable row limit * `FilterControl` cancels active ajax request if any
This commit is contained in:
committed by
Maxime Beauchemin
parent
17635e1a2b
commit
f9202ba179
@@ -28,6 +28,7 @@ export default class FilterControl extends React.Component {
|
||||
}));
|
||||
this.state = {
|
||||
filters: initialFilters,
|
||||
activeRequest: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,16 +46,22 @@ export default class FilterControl extends React.Component {
|
||||
newStateFilters[index].valuesLoading = true;
|
||||
return { filters: newStateFilters };
|
||||
});
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: `/superset/filter/${datasource.type}/${datasource.id}/${col}/`,
|
||||
success: (data) => {
|
||||
this.setState((prevState) => {
|
||||
const newStateFilters = Object.assign([], prevState.filters);
|
||||
newStateFilters[index] = { valuesLoading: false, valueChoices: data };
|
||||
return { filters: newStateFilters };
|
||||
});
|
||||
},
|
||||
// if there is an outstanding request to fetch values, cancel it.
|
||||
if (this.state.activeRequest) {
|
||||
this.state.activeRequest.abort();
|
||||
}
|
||||
this.setState({
|
||||
activeRequest: $.ajax({
|
||||
type: 'GET',
|
||||
url: `/superset/filter/${datasource.type}/${datasource.id}/${col}/`,
|
||||
success: (data) => {
|
||||
this.setState((prevState) => {
|
||||
const newStateFilters = Object.assign([], prevState.filters);
|
||||
newStateFilters[index] = { valuesLoading: false, valueChoices: data };
|
||||
return { filters: newStateFilters, activeRequest: null };
|
||||
});
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user