From e7b53f300a43fa57e8dcb57ba23de85c9e6bcb08 Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Wed, 8 Feb 2023 17:18:45 +0100 Subject: [PATCH] Suche auf den Prospectseiten implementieren --- .../Pages/Prospects.razor | 18 ++++- .../Pages/Prospects.razor.cs | 58 +++++++++----- .../Pages/ProspectsDone.razor | 20 ++++- .../Pages/ProspectsDone.razor.cs | 19 ++++- .../Pages/ProspectsTodo.razor | 19 ++++- .../Pages/ProspectsTodo.razor.cs | 78 ++++++++++++------- 6 files changed, 151 insertions(+), 61 deletions(-) diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor index 8d98bc9..af9c7fa 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor @@ -13,13 +13,23 @@ Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)" >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(); +} -@if (ProspectList?.Any() == true) +
+
@(filterList?.Count ?? 0) Einträge
+ +@if (filterList?.Any() == true) { -
-
@ProspectList.Count Einträge
- +
diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs index c71e0f7..c65d42b 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs @@ -1,4 +1,3 @@ -using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Server.Data.Service; @@ -8,43 +7,48 @@ using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Pages { /// - /// The prospects class (a. beging, 11.04.2022) + /// The prospects class (a. beging, 11.04.2022) /// public partial class Prospects { - #region Dependencies (Injected) + #region Dependencies /// - /// Gets or sets the value of the prospect service (ab) + /// Gets or sets the value of the prospect service (ab) /// [Inject] public ProspectService ProspectService { get; set; } = null!; /// - /// Gets or sets the value of the user service (ab) + /// Gets or sets the value of the user service (ab) /// [Inject] public UserService UserService { get; set; } = null!; #endregion - #region Public Properties + #region Private Properties /// - /// Gets or sets the value of the interaction modal (ab) + /// Gets or sets the value of the filter text (ab) + /// + private string? FilterText { get; set; } + + /// + /// Gets or sets the value of the interaction modal (ab) /// private AddInteractionModal? InteractionModal { get; set; } /// - /// Gets or sets the value of the prospect list (ab) + /// Gets or sets the value of the prospect list (ab) /// private List? ProspectList { get; set; } /// - /// Gets or sets the value of the prospect modal (ab) + /// Gets or sets the value of the prospect modal (ab) /// private AddProspectModal ProspectModal { get; set; } = null!; /// - /// Gets or sets the value of the users (ab) + /// Gets or sets the value of the users (ab) /// private List? Users { get; set; } @@ -53,7 +57,7 @@ namespace FoodsharingSiegen.Server.Pages #region Override OnAfterRenderAsync /// - /// Ons the after render using the specified first render (a. beging, 11.04.2022) + /// Ons the after render using the specified first render (a. beging, 11.04.2022) /// /// The first render protected override async Task OnAfterRenderAsync(bool firstRender) @@ -69,23 +73,36 @@ namespace FoodsharingSiegen.Server.Pages #region Override OnInitializedAsync /// - /// Ons the initialized (a. beging, 11.04.2022) + /// Ons the initialized (a. beging, 11.04.2022) /// protected override async Task OnInitializedAsync() { var getUsersR = await UserService.GetUsersAsync(); if (getUsersR.Success) Users = getUsersR.Data; - + await base.OnInitializedAsync(); } #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 /// - /// Loads the prospects (a. beging, 11.04.2022) + /// Loads the prospects (a. beging, 11.04.2022) /// private async Task LoadProspects() { @@ -95,7 +112,7 @@ namespace FoodsharingSiegen.Server.Pages }; var prospectsR = await ProspectService.GetProspectsAsync(parameter); if (prospectsR.Success) ProspectList = prospectsR.Data; - + await InvokeAsync(StateHasChanged); } @@ -104,7 +121,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method OnAddInteraction /// - /// Ons the add interaction using the specified arg (a. beging, 11.04.2022) + /// Ons the add interaction using the specified arg (a. beging, 11.04.2022) /// /// The arg private async Task OnAddInteraction(Interaction arg) @@ -118,7 +135,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method OnAddProspect /// - /// Ons the add prospect using the specified arg (a. beging, 11.04.2022) + /// Ons the add prospect using the specified arg (a. beging, 11.04.2022) /// /// The arg private async Task OnAddProspect(Prospect arg) @@ -132,7 +149,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method OnUpdateProspect /// - /// Ons the update prospect using the specified prospect (a. beging, 11.04.2022) + /// Ons the update prospect using the specified prospect (a. beging, 11.04.2022) /// /// The prospect private async Task OnUpdateProspect(Prospect prospect) @@ -146,12 +163,13 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method RemoveInteraction /// - /// Removes the interaction using the specified arg (a. beging, 11.04.2022) + /// Removes the interaction using the specified arg (a. beging, 11.04.2022) /// /// The arg private async Task RemoveInteraction(Guid arg) { - var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => { + var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => + { o.ConfirmButtonText = "Ja, wirklich!"; o.CancelButtonText = "Abbrechen"; o.ShowMessageIcon = false; diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor index 4018d1e..81733ca 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor @@ -5,12 +5,24 @@ Abgeschlossene Einarbeitungen

Abgeschlossene Einarbeitungen

-@if (ProspectList?.Any() == true) +@{ + 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(); +} + +
+
@(filterList?.Count ?? 0) Einträge
+ +@if (filterList?.Any() == true) { -
-
@ProspectList.Count Einträge
+
- +
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs index 18fe2d6..03788c9 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs +++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs @@ -1,7 +1,6 @@ using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Server.Data.Service; -using FoodsharingSiegen.Server.Dialogs; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Pages @@ -22,6 +21,11 @@ namespace FoodsharingSiegen.Server.Pages #region Private Properties + /// + /// Gets or sets the value of the filter text (ab) + /// + private string? FilterText { get; set; } + /// /// Gets or sets the value of the prospect list (ab) /// @@ -45,6 +49,19 @@ 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 23e9a54..eca1149 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor @@ -6,13 +6,24 @@

Wartende Einarbeitungen

-@if (ProspectList?.Any() == true) +@{ + 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(); +} + +
+
@(filterList?.Count ?? 0) Einträge
+ +@if (filterList?.Any() == true) { -
-
@ProspectList.Count Einträge
Bereits verifiziert, aber noch nicht abgeschlossen. Zum Beispiel, wenn noch der Druck-Ausweis fehlt o.ä.
- +
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs index 1535e2e..c7ca438 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs +++ b/FoodsharingSiegen.Server/Pages/ProspectsTodo.razor.cs @@ -27,6 +27,11 @@ namespace FoodsharingSiegen.Server.Pages #region Private Properties + /// + /// Gets or sets the value of the filter text (ab) + /// + private string? FilterText { get; set; } + /// /// Gets or sets the value of the interaction modal (ab) /// @@ -36,14 +41,14 @@ namespace FoodsharingSiegen.Server.Pages /// Gets or sets the value of the prospect list (ab) ///
private List? ProspectList { get; set; } - - /// - /// Gets or sets the value of the users (ab) - /// - private List? Users { get; set; } private AddProspectModal? ProspectModal { get; set; } + /// + /// Gets or sets the value of the users (ab) + /// + private List? Users { get; set; } + #endregion #region Override OnAfterRenderAsync @@ -62,6 +67,32 @@ namespace FoodsharingSiegen.Server.Pages #endregion + #region Override OnInitializedAsync + + protected override async Task OnInitializedAsync() + { + var getUsersR = await UserService.GetUsersAsync(); + if (getUsersR.Success) + Users = getUsersR.Data; + + await base.OnInitializedAsync(); + } + + #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 /// @@ -82,15 +113,6 @@ namespace FoodsharingSiegen.Server.Pages #endregion - protected override async Task OnInitializedAsync() - { - var getUsersR = await UserService.GetUsersAsync(); - if (getUsersR.Success) - Users = getUsersR.Data; - - await base.OnInitializedAsync(); - } - #region Private Method OnAddInteraction /// @@ -105,6 +127,20 @@ namespace FoodsharingSiegen.Server.Pages #endregion + #region Private Method OnUpdateProspect + + /// + /// Ons the update prospect using the specified prospect (a. beging, 11.04.2022) + /// + /// The prospect + private async Task OnUpdateProspect(Prospect prospect) + { + var updateProspectR = await ProspectService.UpdateAsync(prospect); + if (updateProspectR.Success) await LoadProspects(); + } + + #endregion + #region Private Method RemoveInteraction /// @@ -130,19 +166,5 @@ namespace FoodsharingSiegen.Server.Pages } #endregion - - #region Private Method OnUpdateProspect - - /// - /// Ons the update prospect using the specified prospect (a. beging, 11.04.2022) - /// - /// The prospect - private async Task OnUpdateProspect(Prospect prospect) - { - var updateProspectR = await ProspectService.UpdateAsync(prospect); - if (updateProspectR.Success) await LoadProspects(); - } - - #endregion } } \ No newline at end of file