mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(plugin-chart-table): Include time control (#23533)
This commit is contained in:
committed by
GitHub
parent
bd0609df58
commit
13ffb4b7c2
@@ -30,6 +30,7 @@ import {
|
|||||||
FormDataResidual,
|
FormDataResidual,
|
||||||
QueryMode,
|
QueryMode,
|
||||||
} from './types/QueryFormData';
|
} from './types/QueryFormData';
|
||||||
|
import { hasGenericChartAxes } from './getXAxis';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra SQL query related fields from chart form data.
|
* Extra SQL query related fields from chart form data.
|
||||||
@@ -105,7 +106,7 @@ export default function extractQueryFields(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (includeTime && !columns.includes(DTTM_ALIAS)) {
|
if (!hasGenericChartAxes && includeTime && !columns.includes(DTTM_ALIAS)) {
|
||||||
columns.unshift(DTTM_ALIAS);
|
columns.unshift(DTTM_ALIAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,20 +327,24 @@ const config: ControlPanelConfig = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
!hasGenericChartAxes
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
name: 'include_time',
|
||||||
|
config: {
|
||||||
|
type: 'CheckboxControl',
|
||||||
|
label: t('Include time'),
|
||||||
|
description: t(
|
||||||
|
'Whether to include the time granularity as defined in the time section',
|
||||||
|
),
|
||||||
|
default: false,
|
||||||
|
visibility: isAggMode,
|
||||||
|
resetOnHide: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [null],
|
||||||
[
|
[
|
||||||
{
|
|
||||||
name: 'include_time',
|
|
||||||
config: {
|
|
||||||
type: 'CheckboxControl',
|
|
||||||
label: t('Include time'),
|
|
||||||
description: t(
|
|
||||||
'Whether to include the time granularity as defined in the time section',
|
|
||||||
),
|
|
||||||
default: false,
|
|
||||||
visibility: isAggMode,
|
|
||||||
resetOnHide: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'order_desc',
|
name: 'order_desc',
|
||||||
config: {
|
config: {
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ import { Dispatch } from 'redux';
|
|||||||
import {
|
import {
|
||||||
ensureIsArray,
|
ensureIsArray,
|
||||||
getCategoricalSchemeRegistry,
|
getCategoricalSchemeRegistry,
|
||||||
|
getColumnLabel,
|
||||||
getSequentialSchemeRegistry,
|
getSequentialSchemeRegistry,
|
||||||
|
hasGenericChartAxes,
|
||||||
NO_TIME_RANGE,
|
NO_TIME_RANGE,
|
||||||
|
QueryFormColumn,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import {
|
import {
|
||||||
getFormDataFromControls,
|
getFormDataFromControls,
|
||||||
@@ -73,6 +76,23 @@ export const hydrateExplore =
|
|||||||
initialFormData.time_range =
|
initialFormData.time_range =
|
||||||
common?.conf?.DEFAULT_TIME_FILTER || NO_TIME_RANGE;
|
common?.conf?.DEFAULT_TIME_FILTER || NO_TIME_RANGE;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
hasGenericChartAxes &&
|
||||||
|
initialFormData.include_time &&
|
||||||
|
initialFormData.granularity_sqla &&
|
||||||
|
!initialFormData.groupby?.some(
|
||||||
|
(col: QueryFormColumn) =>
|
||||||
|
getColumnLabel(col) ===
|
||||||
|
getColumnLabel(initialFormData.granularity_sqla!),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
initialFormData.groupby = [
|
||||||
|
initialFormData.granularity_sqla,
|
||||||
|
...ensureIsArray(initialFormData.groupby),
|
||||||
|
];
|
||||||
|
initialFormData.granularity_sqla = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (dashboardId) {
|
if (dashboardId) {
|
||||||
initialFormData.dashboardId = dashboardId;
|
initialFormData.dashboardId = dashboardId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user