This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 78833bcc30 fix: Native time range filter in legacy charts (#23865)
78833bcc30 is described below

commit 78833bcc3068968ac62959dd541afd00c7e11c24
Author: Kamil Gabryjelski <[email protected]>
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 5da7e61ac3..4569031f3f 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -1161,6 +1161,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:

Reply via email to