From 51b6e828df3c91606471d2d51cc09e39179cb5c0 Mon Sep 17 00:00:00 2001 From: jansule Date: Fri, 28 Jun 2024 15:06:21 +0200 Subject: [PATCH] feat(plugin-chart-cartodiagram): add support for dashboard filters --- .../src/plugin/buildQuery.ts | 14 ++++++++++++-- .../test/plugin/buildQuery.test.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-cartodiagram/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-cartodiagram/src/plugin/buildQuery.ts index 93ad49d0322f3..23405382e6198 100644 --- a/superset-frontend/plugins/plugin-chart-cartodiagram/src/plugin/buildQuery.ts +++ b/superset-frontend/plugins/plugin-chart-cartodiagram/src/plugin/buildQuery.ts @@ -33,11 +33,21 @@ import { QueryFormData, getChartBuildQueryRegistry } from '@superset-ui/core'; * if a viz needs multiple different result sets. */ export default function buildQuery(formData: QueryFormData) { - const { selected_chart: selectedChartString, geom_column: geometryColumn } = - formData; + const { + selected_chart: selectedChartString, + geom_column: geometryColumn, + extra_form_data: extraFormData, + } = formData; const selectedChart = JSON.parse(selectedChartString); const vizType = selectedChart.viz_type; const chartFormData = JSON.parse(selectedChart.params); + // Pass extra_form_data to chartFormData so that + // dashboard filters will also be applied to the charts + // on the map. + chartFormData.extra_form_data = { + ...chartFormData.extra_form_data, + ...extraFormData, + }; // adapt groupby property to ensure geometry column always exists // and is always at first position diff --git a/superset-frontend/plugins/plugin-chart-cartodiagram/test/plugin/buildQuery.test.ts b/superset-frontend/plugins/plugin-chart-cartodiagram/test/plugin/buildQuery.test.ts index 0c8b8c049a1ee..7b0da000e58fb 100644 --- a/superset-frontend/plugins/plugin-chart-cartodiagram/test/plugin/buildQuery.test.ts +++ b/superset-frontend/plugins/plugin-chart-cartodiagram/test/plugin/buildQuery.test.ts @@ -21,6 +21,7 @@ import buildQuery from '../../src/plugin/buildQuery'; describe('CartodiagramPlugin buildQuery', () => { const selectedChartParams = { + extra_form_data: {}, groupby: [], };