mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +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:
@@ -93,6 +93,26 @@ export function changeFilter(filter, field, value) {
|
||||
return { type: CHANGE_FILTER, filter, field, value };
|
||||
}
|
||||
|
||||
export function fetchFilterValues(datasource_type, datasource_id, filter, col) {
|
||||
return function (dispatch) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: `/superset/filter/${datasource_type}/${datasource_id}/${col}/`,
|
||||
success: (data) => {
|
||||
dispatch(changeFilter(
|
||||
filter,
|
||||
'choices',
|
||||
Object.keys(data).map((k) => ([`'${data[k]}'`, `'${data[k]}'`]))
|
||||
)
|
||||
);
|
||||
},
|
||||
error() {
|
||||
dispatch(changeFilter(filter, 'choices', []));
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const SET_FIELD_VALUE = 'SET_FIELD_VALUE';
|
||||
export function setFieldValue(datasource_type, key, value, label) {
|
||||
return { type: SET_FIELD_VALUE, datasource_type, key, value, label };
|
||||
|
||||
Reference in New Issue
Block a user