From 69eb41e716e9aeca3adcf0812ef3025319701667 Mon Sep 17 00:00:00 2001 From: Brian Lagunas <835562+brianlagunas@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:00:23 -0600 Subject: [PATCH] supported custom field name for dashboard filter connections --- .../Filters/Bindings/DashboardDataFilterBinding.cs | 9 ++++++--- .../Bindings/DashboardDateFilterBindingTarget.cs | 2 +- src/Reveal.Sdk.Dom/Filters/DashboardDataFilter.cs | 2 +- .../Extensions/IFilterBindingsExtensions.cs | 13 ++++++++++--- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Reveal.Sdk.Dom/Filters/Bindings/DashboardDataFilterBinding.cs b/src/Reveal.Sdk.Dom/Filters/Bindings/DashboardDataFilterBinding.cs index 75e05dd9..b6a1c288 100644 --- a/src/Reveal.Sdk.Dom/Filters/Bindings/DashboardDataFilterBinding.cs +++ b/src/Reveal.Sdk.Dom/Filters/Bindings/DashboardDataFilterBinding.cs @@ -5,13 +5,16 @@ public sealed class DashboardDataFilterBinding : Binding(this T visualization, DashboardFilter dashboardFilter) where T : IFilterBindings + { + return visualization.ConnectDashboardFilter(dashboardFilter, null); + } + + public static T ConnectDashboardFilter(this T visualization, DashboardFilter dashboardFilter, string fieldName) + where T : IFilterBindings { if (dashboardFilter is DashboardDateFilter) { - visualization.FilterBindings.Add(new DashboardDateFilterBinding("Date")); + visualization.FilterBindings.Add(new DashboardDateFilterBinding(fieldName ?? "Date")); } - else + else if (dashboardFilter is DashboardDataFilter dataFilter) { - visualization.FilterBindings.Add(new DashboardDataFilterBinding(dashboardFilter as DashboardDataFilter)); + var binding = fieldName == null ? new DashboardDataFilterBinding(dataFilter) : new DashboardDataFilterBinding(dataFilter, fieldName); + visualization.FilterBindings.Add(binding); } return visualization; }