From 7efd48c79446cbd3207ed7fef3d6cf5ae5514235 Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Thu, 27 Mar 2025 18:42:21 +0100 Subject: [PATCH] Prospect filter --- .../Model/ProspectFilter.cs | 9 +++++ .../Controls/ProspectFilterControl.razor | 35 +++++++++++++++++++ .../Pages/Prospects.razor | 28 ++++++++++----- .../Pages/Prospects.razor.cs | 20 ++--------- .../Pages/ProspectsDone.razor | 24 ++++++++----- .../Pages/ProspectsDone.razor.cs | 18 +--------- .../Pages/ProspectsTodo.razor | 24 ++++++++----- .../Pages/ProspectsTodo.razor.cs | 18 +--------- 8 files changed, 99 insertions(+), 77 deletions(-) create mode 100644 FoodsharingSiegen.Contracts/Model/ProspectFilter.cs create mode 100644 FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor diff --git a/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs b/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs new file mode 100644 index 0000000..c3a5dc7 --- /dev/null +++ b/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs @@ -0,0 +1,9 @@ +namespace FoodsharingSiegen.Contracts.Model +{ + public class ProspectFilter + { + public string? Text { get; set; } + + public bool WithoutStepInBriefing { get; set; } + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor new file mode 100644 index 0000000..9c86e78 --- /dev/null +++ b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor @@ -0,0 +1,35 @@ +@using FoodsharingSiegen.Contracts.Model +@code { + + [Parameter] + public ProspectFilter Filter { get; set; } = new(); + + [Parameter] + public EventCallback FilterChanged { get; set; } + + + private async Task WithoutStepInBriefingChangedAsync(bool arg) + { + Filter.WithoutStepInBriefing = arg; + await FilterChanged.InvokeAsync(Filter); + } + + private async Task TextChanged(string arg) + { + Filter.Text = arg; + await FilterChanged.InvokeAsync(Filter); + } + +} + +
+
+ Suchfilter +
+
+
+ Ohne Neulingstreffen +
+ +
+
\ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor index 888bceb..0a2320e 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor @@ -11,21 +11,31 @@ Color="Color.Primary" Clicked="() => ProspectModal.Show()" Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)" - >Hinzufügen +>Hinzufügen + @{ - var filterList = ProspectList; - if(!string.IsNullOrWhiteSpace(FilterText)) - filterList = filterList?.Where(x => - x.Name.Contains(FilterText, StringComparison.OrdinalIgnoreCase) || - x.Memo?.Contains(FilterText, StringComparison.OrdinalIgnoreCase) == true || - x.FsId.ToString().Contains(FilterText, StringComparison.OrdinalIgnoreCase)) - .ToList(); + var filterListQ = ProspectList?.AsQueryable(); + if (!string.IsNullOrWhiteSpace(Filter.Text)) + { + filterListQ = filterListQ? + .Where(x => + x.Name.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) || + (!string.IsNullOrWhiteSpace(x.Memo) && x.Memo.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) == true) || + x.FsId.ToString().Contains(Filter.Text, StringComparison.OrdinalIgnoreCase)).AsQueryable(); + } + + if (Filter.WithoutStepInBriefing) + filterListQ = filterListQ?.Where(x => x.Interactions.All(i => i.Type != InteractionType.StepInBriefing)); + + var filterList = filterListQ?.ToList(); } +
+
@(filterList?.Count ?? 0) Einträge
- + @if (filterList?.Any() == true) {
diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs index 8cc3580..6c9e537 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs @@ -29,11 +29,8 @@ namespace FoodsharingSiegen.Server.Pages #region Private Properties - /// - /// Gets or sets the value of the filter text (ab) - /// - private string? FilterText { get; set; } - + private ProspectFilter Filter { get; set; } = new(); + /// /// Gets or sets the value of the interaction modal (ab) /// @@ -72,19 +69,6 @@ namespace FoodsharingSiegen.Server.Pages #endregion - #region Private Method FilterText_Changed - - /// - /// Filters the text changed using the specified filter text (a. beging, 08.02.2023) - /// - /// The filter text - private void FilterText_Changed(string filterText) - { - FilterText = filterText; - } - - #endregion - #region Private Method LoadProspects /// diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor index c998faf..1f73b5b 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor @@ -6,18 +6,26 @@

Abgeschlossene Einarbeitungen

@{ - var filterList = ProspectList; - if(!string.IsNullOrWhiteSpace(FilterText)) - filterList = filterList?.Where(x => - x.Name.Contains(FilterText, StringComparison.OrdinalIgnoreCase) || - x.Memo?.Contains(FilterText, StringComparison.OrdinalIgnoreCase) == true || - x.FsId.ToString().Contains(FilterText, StringComparison.OrdinalIgnoreCase)) - .ToList(); + var filterListQ = ProspectList?.AsQueryable(); + if (!string.IsNullOrWhiteSpace(Filter.Text)) + { + filterListQ = filterListQ? + .Where(x => + x.Name.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) || + (!string.IsNullOrWhiteSpace(x.Memo) && x.Memo.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) == true) || + x.FsId.ToString().Contains(Filter.Text, StringComparison.OrdinalIgnoreCase)).AsQueryable(); + } + + if (Filter.WithoutStepInBriefing) + filterListQ = filterListQ?.Where(x => x.Interactions.All(i => i.Type != InteractionType.StepInBriefing)); + + var filterList = filterListQ?.ToList(); } +
+
@(filterList?.Count ?? 0) Einträge
- @if (filterList?.Any() == true) { diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs index 1d5d49a..4987cf7 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs @@ -22,10 +22,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Properties - /// - /// Gets or sets the value of the filter text (ab) - /// - private string? FilterText { get; set; } + private ProspectFilter Filter { get; set; } = new(); /// /// Gets or sets the value of the prospect list (ab) @@ -44,19 +41,6 @@ namespace FoodsharingSiegen.Server.Pages #endregion - #region Private Method FilterText_Changed - - /// - /// Filters the text changed using the specified filter text (a. beging, 08.02.2023) - /// - /// The filter text - private void FilterText_Changed(string filterText) - { - FilterText = filterText; - } - - #endregion - #region Private Method LoadProspects /// diff --git a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor index 469794a..92e3f66 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor @@ -7,18 +7,26 @@

Freischalten

@{ - var filterList = ProspectList; - if(!string.IsNullOrWhiteSpace(FilterText)) - filterList = filterList?.Where(x => - x.Name.Contains(FilterText, StringComparison.OrdinalIgnoreCase) || - x.Memo?.Contains(FilterText, StringComparison.OrdinalIgnoreCase) == true || - x.FsId.ToString().Contains(FilterText, StringComparison.OrdinalIgnoreCase)) - .ToList(); + var filterListQ = ProspectList?.AsQueryable(); + if (!string.IsNullOrWhiteSpace(Filter.Text)) + { + filterListQ = filterListQ? + .Where(x => + x.Name.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) || + (!string.IsNullOrWhiteSpace(x.Memo) && x.Memo.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) == true) || + x.FsId.ToString().Contains(Filter.Text, StringComparison.OrdinalIgnoreCase)).AsQueryable(); + } + + if (Filter.WithoutStepInBriefing) + filterListQ = filterListQ?.Where(x => x.Interactions.All(i => i.Type != InteractionType.StepInBriefing)); + + var filterList = filterListQ?.ToList(); } +
+
@(filterList?.Count ?? 0) Einträge
- @if (filterList?.Any() == true) {
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs index 366a245..46873f8 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs @@ -29,10 +29,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Properties - /// - /// Gets or sets the value of the filter text (ab) - /// - private string? FilterText { get; set; } + private ProspectFilter Filter { get; set; } = new(); /// /// Gets or sets the value of the interaction modal (ab) @@ -69,19 +66,6 @@ namespace FoodsharingSiegen.Server.Pages #endregion - #region Private Method FilterText_Changed - - /// - /// Filters the text changed using the specified filter text (a. beging, 08.02.2023) - /// - /// The filter text - private void FilterText_Changed(string filterText) - { - FilterText = filterText; - } - - #endregion - #region Private Method LoadProspects ///