mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[filter_box] Fix ; separated filter_box default values (#8949)
This commit is contained in:
@@ -62,7 +62,26 @@ describe('getFilterConfigsFromFormdata', () => {
|
||||
show_sqla_time_column: true,
|
||||
});
|
||||
expect(result.columns).toMatchObject({
|
||||
state: 'CA',
|
||||
state: ['CA'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should read multi values from form_data', () => {
|
||||
const result = getFilterConfigsFromFormdata({
|
||||
...testFormdata,
|
||||
filter_configs: [
|
||||
{
|
||||
asc: true,
|
||||
clearable: true,
|
||||
column: 'state',
|
||||
defaultValue: 'CA;NY',
|
||||
key: 'fvwncPjUf',
|
||||
multiple: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(result.columns).toMatchObject({
|
||||
state: ['CA', 'NY'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,9 +31,15 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
|
||||
} = form_data;
|
||||
let configs = filter_configs.reduce(
|
||||
({ columns, labels }, config) => {
|
||||
let defaultValues = config.defaultValue;
|
||||
// defaultValue could be ; separated values,
|
||||
// could be null or ''
|
||||
if (config.defaultValue) {
|
||||
defaultValues = config.defaultValue.split(';');
|
||||
}
|
||||
const updatedColumns = {
|
||||
...columns,
|
||||
[config.column]: config.vals || config.defaultValue,
|
||||
[config.column]: config.vals || defaultValues,
|
||||
};
|
||||
const updatedLabels = {
|
||||
...labels,
|
||||
|
||||
Reference in New Issue
Block a user