mirror of https://github.com/apache/superset.git
[filter_box] dashboard should carry defaultValue in filter_box (#8812)
This commit is contained in:
parent
ed54f6ec8d
commit
1d3c93ccb2
|
@ -20,6 +20,16 @@ import getFilterConfigsFromFormdata from '../../../../src/dashboard/util/getFilt
|
|||
|
||||
describe('getFilterConfigsFromFormdata', () => {
|
||||
const testFormdata = {
|
||||
filter_configs: [
|
||||
{
|
||||
asc: true,
|
||||
clearable: true,
|
||||
column: 'state',
|
||||
defaultValue: 'CA',
|
||||
key: 'fvwncPjUf',
|
||||
multiple: true,
|
||||
},
|
||||
],
|
||||
date_filter: true,
|
||||
granularity_sqla: '__time',
|
||||
time_grain_sqla: 'P1M',
|
||||
|
@ -45,4 +55,14 @@ describe('getFilterConfigsFromFormdata', () => {
|
|||
__time_col: testFormdata.granularity_sqla,
|
||||
});
|
||||
});
|
||||
|
||||
it('should use default value from form_data', () => {
|
||||
const result = getFilterConfigsFromFormdata({
|
||||
...testFormdata,
|
||||
show_sqla_time_column: true,
|
||||
});
|
||||
expect(result.columns).toMatchObject({
|
||||
state: 'CA',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
|
|||
({ columns, labels }, config) => {
|
||||
const updatedColumns = {
|
||||
...columns,
|
||||
[config.column]: config.vals,
|
||||
[config.column]: config.vals || config.defaultValue,
|
||||
};
|
||||
const updatedLabels = {
|
||||
...labels,
|
||||
|
|
Loading…
Reference in New Issue