mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[filter_box] Fix show time column in filter_box (#8740)
This commit is contained in:
parent
b0b93768bb
commit
89950440f2
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
import getFilterConfigsFromFormdata from '../../../../src/dashboard/util/getFilterConfigsFromFormdata';
|
||||||
|
|
||||||
|
describe('getFilterConfigsFromFormdata', () => {
|
||||||
|
const testFormdata = {
|
||||||
|
date_filter: true,
|
||||||
|
granularity_sqla: '__time',
|
||||||
|
time_grain_sqla: 'P1M',
|
||||||
|
time_range: '2018-12-30T00:00:00+:+last+saturday',
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should add time grain', () => {
|
||||||
|
const result = getFilterConfigsFromFormdata({
|
||||||
|
...testFormdata,
|
||||||
|
show_sqla_time_granularity: true,
|
||||||
|
});
|
||||||
|
expect(result.columns).toMatchObject({
|
||||||
|
__time_grain: testFormdata.time_grain_sqla,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add time column', () => {
|
||||||
|
const result = getFilterConfigsFromFormdata({
|
||||||
|
...testFormdata,
|
||||||
|
show_sqla_time_column: true,
|
||||||
|
});
|
||||||
|
expect(result.columns).toMatchObject({
|
||||||
|
__time_col: testFormdata.granularity_sqla,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -61,14 +61,14 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
|
|||||||
[TIME_FILTER_MAP.time_range]: FILTER_LABELS[TIME_RANGE],
|
[TIME_FILTER_MAP.time_range]: FILTER_LABELS[TIME_RANGE],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (show_sqla_time_column) {
|
if (show_sqla_time_granularity) {
|
||||||
updatedColumns = {
|
updatedColumns = {
|
||||||
...updatedColumns,
|
...updatedColumns,
|
||||||
[TIME_FILTER_MAP.time_grain_sqla]: form_data.time_grain_sqla,
|
[TIME_FILTER_MAP.time_grain_sqla]: form_data.time_grain_sqla,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_sqla_time_granularity) {
|
if (show_sqla_time_column) {
|
||||||
updatedColumns = {
|
updatedColumns = {
|
||||||
...updatedColumns,
|
...updatedColumns,
|
||||||
[TIME_FILTER_MAP.granularity_sqla]: form_data.granularity_sqla,
|
[TIME_FILTER_MAP.granularity_sqla]: form_data.granularity_sqla,
|
||||||
|
Loading…
Reference in New Issue
Block a user