mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[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', () => {
|
describe('getFilterConfigsFromFormdata', () => {
|
||||||
const testFormdata = {
|
const testFormdata = {
|
||||||
|
filter_configs: [
|
||||||
|
{
|
||||||
|
asc: true,
|
||||||
|
clearable: true,
|
||||||
|
column: 'state',
|
||||||
|
defaultValue: 'CA',
|
||||||
|
key: 'fvwncPjUf',
|
||||||
|
multiple: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
date_filter: true,
|
date_filter: true,
|
||||||
granularity_sqla: '__time',
|
granularity_sqla: '__time',
|
||||||
time_grain_sqla: 'P1M',
|
time_grain_sqla: 'P1M',
|
||||||
@ -45,4 +55,14 @@ describe('getFilterConfigsFromFormdata', () => {
|
|||||||
__time_col: testFormdata.granularity_sqla,
|
__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) => {
|
({ columns, labels }, config) => {
|
||||||
const updatedColumns = {
|
const updatedColumns = {
|
||||||
...columns,
|
...columns,
|
||||||
[config.column]: config.vals,
|
[config.column]: config.vals || config.defaultValue,
|
||||||
};
|
};
|
||||||
const updatedLabels = {
|
const updatedLabels = {
|
||||||
...labels,
|
...labels,
|
||||||
|
Loading…
Reference in New Issue
Block a user