From b5caf0d706599918deb7cdbec007be6496427536 Mon Sep 17 00:00:00 2001 From: Arnei Date: Thu, 20 Feb 2025 11:34:15 +0100 Subject: [PATCH 1/2] Allow stats to set textfilter The stats over the events table (Today, Running etc.) can set filters for the events table if clicked on. However, it was not possible to use this to set a textfilter (text in the search field). This patch fixes that. --- src/components/shared/Stats.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/shared/Stats.tsx b/src/components/shared/Stats.tsx index 2266bba353..1e3abc9174 100644 --- a/src/components/shared/Stats.tsx +++ b/src/components/shared/Stats.tsx @@ -6,6 +6,7 @@ import { resetFilterValues, fetchStats, Stats as StatsType, + editTextFilter, } from "../../slices/tableFilterSlice"; import { loadEventsIntoTable } from "../../thunks/tableThunks"; import { useAppDispatch, useAppSelector } from "../../store"; @@ -26,6 +27,10 @@ const Stats = () => { dispatch(resetFilterValues()); let filterValue; await stats.filters.forEach((f) => { + if (f.name.toLowerCase() === "textfilter") { + dispatch(editTextFilter(f.value)) + return; + } let filter = filterMap.find(({ name }) => name === f.name); filterValue = f.value; if (!!filter) { From a6ca862cba09abe12e8cc0e29b9b29bd776e7335 Mon Sep 17 00:00:00 2001 From: Arnei Date: Tue, 25 Feb 2025 14:46:48 +0100 Subject: [PATCH 2/2] Have stats button reset textfilter Usually if the user clicks on the stats button, they want to filter by exactly what the button promises, without the results being further influenced by a textfilter. --- src/components/shared/Stats.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/shared/Stats.tsx b/src/components/shared/Stats.tsx index 1e3abc9174..190a0cba8a 100644 --- a/src/components/shared/Stats.tsx +++ b/src/components/shared/Stats.tsx @@ -7,6 +7,7 @@ import { fetchStats, Stats as StatsType, editTextFilter, + removeTextFilter, } from "../../slices/tableFilterSlice"; import { loadEventsIntoTable } from "../../thunks/tableThunks"; import { useAppDispatch, useAppSelector } from "../../store"; @@ -28,8 +29,10 @@ const Stats = () => { let filterValue; await stats.filters.forEach((f) => { if (f.name.toLowerCase() === "textfilter") { - dispatch(editTextFilter(f.value)) + dispatch(editTextFilter(f.value)); return; + } else { + dispatch(removeTextFilter()); } let filter = filterMap.find(({ name }) => name === f.name); filterValue = f.value;