mirror of https://github.com/apache/superset.git
[dashboard scoped filters] Add all time related options to filter scope settings (#8636)
This commit is contained in:
parent
f04b72c341
commit
acf0753504
|
@ -24,6 +24,7 @@ import {
|
|||
getDashboardFilterKey,
|
||||
} from './getDashboardFilterKey';
|
||||
import { CHART_TYPE } from '../util/componentTypes';
|
||||
import { DASHBOARD_FILTER_SCOPE_GLOBAL } from '../reducers/dashboardFilters';
|
||||
|
||||
let allFilterBoxChartIds = [];
|
||||
let activeFilters = {};
|
||||
|
@ -61,7 +62,9 @@ export function getAppliedFilterValues(chartId) {
|
|||
return appliedFilterValuesByChart[chartId];
|
||||
}
|
||||
|
||||
export function getChartIdsInFilterScope({ filterScope }) {
|
||||
export function getChartIdsInFilterScope({
|
||||
filterScope = DASHBOARD_FILTER_SCOPE_GLOBAL,
|
||||
}) {
|
||||
function traverse(chartIds = [], component = {}, immuneChartIds = []) {
|
||||
if (!component) {
|
||||
return;
|
||||
|
|
|
@ -18,12 +18,20 @@
|
|||
*/
|
||||
/* eslint-disable camelcase */
|
||||
import {
|
||||
TIME_FILTER_MAP,
|
||||
TIME_RANGE,
|
||||
FILTER_LABELS,
|
||||
} from '../../visualizations/FilterBox/FilterBox';
|
||||
|
||||
export default function getFilterConfigsFromFormdata(form_data = {}) {
|
||||
const { date_filter, filter_configs = [] } = form_data;
|
||||
const {
|
||||
date_filter,
|
||||
filter_configs = [],
|
||||
show_druid_time_granularity,
|
||||
show_druid_time_origin,
|
||||
show_sqla_time_column,
|
||||
show_sqla_time_granularity,
|
||||
} = form_data;
|
||||
let configs = filter_configs.reduce(
|
||||
({ columns, labels }, config) => {
|
||||
const updatedColumns = {
|
||||
|
@ -44,15 +52,43 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
|
|||
);
|
||||
|
||||
if (date_filter) {
|
||||
const updatedColumns = {
|
||||
let updatedColumns = {
|
||||
...configs.columns,
|
||||
[TIME_RANGE]: form_data[TIME_RANGE],
|
||||
[TIME_FILTER_MAP.time_range]: form_data.time_range,
|
||||
};
|
||||
const updatedLabels = {
|
||||
...configs.labels,
|
||||
[TIME_RANGE]: FILTER_LABELS[TIME_RANGE],
|
||||
[TIME_FILTER_MAP.time_range]: FILTER_LABELS[TIME_RANGE],
|
||||
};
|
||||
|
||||
if (show_sqla_time_column) {
|
||||
updatedColumns = {
|
||||
...updatedColumns,
|
||||
[TIME_FILTER_MAP.time_grain_sqla]: form_data.time_grain_sqla,
|
||||
};
|
||||
}
|
||||
|
||||
if (show_sqla_time_granularity) {
|
||||
updatedColumns = {
|
||||
...updatedColumns,
|
||||
[TIME_FILTER_MAP.granularity_sqla]: form_data.granularity_sqla,
|
||||
};
|
||||
}
|
||||
|
||||
if (show_druid_time_granularity) {
|
||||
updatedColumns = {
|
||||
...updatedColumns,
|
||||
[TIME_FILTER_MAP.granularity]: form_data.granularity,
|
||||
};
|
||||
}
|
||||
|
||||
if (show_druid_time_origin) {
|
||||
updatedColumns = {
|
||||
...updatedColumns,
|
||||
[TIME_FILTER_MAP.druid_time_origin]: form_data.druid_time_origin,
|
||||
};
|
||||
}
|
||||
|
||||
configs = {
|
||||
...configs,
|
||||
columns: updatedColumns,
|
||||
|
|
|
@ -36,7 +36,7 @@ import FilterBadgeIcon from '../../components/FilterBadgeIcon';
|
|||
import './FilterBox.less';
|
||||
|
||||
// maps control names to their key in extra_filters
|
||||
const TIME_FILTER_MAP = {
|
||||
export const TIME_FILTER_MAP = {
|
||||
time_range: '__time_range',
|
||||
granularity_sqla: '__time_col',
|
||||
time_grain_sqla: '__time_grain',
|
||||
|
@ -44,7 +44,8 @@ const TIME_FILTER_MAP = {
|
|||
granularity: '__granularity',
|
||||
};
|
||||
|
||||
export const TIME_RANGE = '__time_range';
|
||||
// a shortcut to a map key, used by many components
|
||||
export const TIME_RANGE = TIME_FILTER_MAP.time_range;
|
||||
export const FILTER_LABELS = {
|
||||
[TIME_RANGE]: 'Time range',
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue