You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/07/07 22:41:39 UTC
[superset] 09/12: fix: Native time range filter in legacy charts (#23865)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7155dcd5df03031fcf45f4300f425f7b85751dea
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Mon May 1 18:57:20 2023 +0200
fix: Native time range filter in legacy charts (#23865)
---
.../plugins/legacy-plugin-chart-calendar/src/controlPanel.ts | 8 ++++++--
superset/utils/core.py | 8 ++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/controlPanel.ts
index 9071a278ee..6cdd79162b 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/controlPanel.ts
+++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/controlPanel.ts
@@ -22,12 +22,16 @@ import {
D3_FORMAT_DOCS,
D3_TIME_FORMAT_OPTIONS,
getStandardizedControls,
- sections,
} from '@superset-ui/chart-controls';
const config: ControlPanelConfig = {
controlPanelSections: [
- sections.legacyRegularTime,
+ {
+ label: t('Time'),
+ expanded: true,
+ description: t('Time related form attributes'),
+ controlSetRows: [['granularity_sqla'], ['time_range']],
+ },
{
label: t('Query'),
expanded: true,
diff --git a/superset/utils/core.py b/superset/utils/core.py
index 22ff3f8be4..8cf73b84aa 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -1159,6 +1159,14 @@ def merge_extra_form_data(form_data: Dict[str, Any]) -> None:
for fltr in append_filters
if fltr
)
+ if (
+ form_data.get("time_range")
+ and not form_data.get("granularity")
+ and not form_data.get("granularity_sqla")
+ ):
+ for adhoc_filter in form_data.get("adhoc_filters", []):
+ if adhoc_filter.get("operator") == "TEMPORAL_RANGE":
+ adhoc_filter["comparator"] = form_data["time_range"]
def merge_extra_filters(form_data: Dict[str, Any]) -> None: