Suche auf den Prospectseiten implementieren

This commit is contained in:
Andre Beging
2023-02-08 17:18:45 +01:00
parent c19db96b2c
commit e7b53f300a
6 changed files with 151 additions and 61 deletions

View File

@@ -13,13 +13,23 @@
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)" Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
>Hinzufügen</Button> >Hinzufügen</Button>
@{
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) <hr />
<h5>@(filterList?.Count ?? 0) Einträge</h5>
<TextEdit TextChanged="FilterText_Changed" Placeholder="Suchen..." Debounce="true" DebounceInterval="150" />
@if (filterList?.Any() == true)
{ {
<hr />
<h5>@ProspectList.Count Einträge</h5>
<div class="row m-0"> <div class="row m-0">
<Repeater Items="@ProspectList"> <Repeater Items="@filterList">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer> <ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater> </Repeater>
</div> </div>

View File

@@ -1,4 +1,3 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
@@ -8,43 +7,48 @@ using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages namespace FoodsharingSiegen.Server.Pages
{ {
/// <summary> /// <summary>
/// The prospects class (a. beging, 11.04.2022) /// The prospects class (a. beging, 11.04.2022)
/// </summary> /// </summary>
public partial class Prospects public partial class Prospects
{ {
#region Dependencies (Injected) #region Dependencies
/// <summary> /// <summary>
/// Gets or sets the value of the prospect service (ab) /// Gets or sets the value of the prospect service (ab)
/// </summary> /// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!; [Inject] public ProspectService ProspectService { get; set; } = null!;
/// <summary> /// <summary>
/// Gets or sets the value of the user service (ab) /// Gets or sets the value of the user service (ab)
/// </summary> /// </summary>
[Inject] public UserService UserService { get; set; } = null!; [Inject] public UserService UserService { get; set; } = null!;
#endregion #endregion
#region Public Properties #region Private Properties
/// <summary> /// <summary>
/// Gets or sets the value of the interaction modal (ab) /// Gets or sets the value of the filter text (ab)
/// </summary>
private string? FilterText { get; set; }
/// <summary>
/// Gets or sets the value of the interaction modal (ab)
/// </summary> /// </summary>
private AddInteractionModal? InteractionModal { get; set; } private AddInteractionModal? InteractionModal { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the prospect list (ab) /// Gets or sets the value of the prospect list (ab)
/// </summary> /// </summary>
private List<Prospect>? ProspectList { get; set; } private List<Prospect>? ProspectList { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the prospect modal (ab) /// Gets or sets the value of the prospect modal (ab)
/// </summary> /// </summary>
private AddProspectModal ProspectModal { get; set; } = null!; private AddProspectModal ProspectModal { get; set; } = null!;
/// <summary> /// <summary>
/// Gets or sets the value of the users (ab) /// Gets or sets the value of the users (ab)
/// </summary> /// </summary>
private List<User>? Users { get; set; } private List<User>? Users { get; set; }
@@ -53,7 +57,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnAfterRenderAsync #region Override OnAfterRenderAsync
/// <summary> /// <summary>
/// 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)
/// </summary> /// </summary>
/// <param name="firstRender">The first render</param> /// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
@@ -69,23 +73,36 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnInitializedAsync #region Override OnInitializedAsync
/// <summary> /// <summary>
/// Ons the initialized (a. beging, 11.04.2022) /// Ons the initialized (a. beging, 11.04.2022)
/// </summary> /// </summary>
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
var getUsersR = await UserService.GetUsersAsync(); var getUsersR = await UserService.GetUsersAsync();
if (getUsersR.Success) if (getUsersR.Success)
Users = getUsersR.Data; Users = getUsersR.Data;
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
#endregion #endregion
#region Private Method FilterText_Changed
/// <summary>
/// Filters the text changed using the specified filter text (a. beging, 08.02.2023)
/// </summary>
/// <param name="filterText">The filter text</param>
private void FilterText_Changed(string filterText)
{
FilterText = filterText;
}
#endregion
#region Private Method LoadProspects #region Private Method LoadProspects
/// <summary> /// <summary>
/// Loads the prospects (a. beging, 11.04.2022) /// Loads the prospects (a. beging, 11.04.2022)
/// </summary> /// </summary>
private async Task LoadProspects() private async Task LoadProspects()
{ {
@@ -95,7 +112,7 @@ namespace FoodsharingSiegen.Server.Pages
}; };
var prospectsR = await ProspectService.GetProspectsAsync(parameter); var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data; if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} }
@@ -104,7 +121,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnAddInteraction #region Private Method OnAddInteraction
/// <summary> /// <summary>
/// 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)
/// </summary> /// </summary>
/// <param name="arg">The arg</param> /// <param name="arg">The arg</param>
private async Task OnAddInteraction(Interaction arg) private async Task OnAddInteraction(Interaction arg)
@@ -118,7 +135,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnAddProspect #region Private Method OnAddProspect
/// <summary> /// <summary>
/// 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)
/// </summary> /// </summary>
/// <param name="arg">The arg</param> /// <param name="arg">The arg</param>
private async Task OnAddProspect(Prospect arg) private async Task OnAddProspect(Prospect arg)
@@ -132,7 +149,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnUpdateProspect #region Private Method OnUpdateProspect
/// <summary> /// <summary>
/// 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)
/// </summary> /// </summary>
/// <param name="prospect">The prospect</param> /// <param name="prospect">The prospect</param>
private async Task OnUpdateProspect(Prospect prospect) private async Task OnUpdateProspect(Prospect prospect)
@@ -146,12 +163,13 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method RemoveInteraction #region Private Method RemoveInteraction
/// <summary> /// <summary>
/// Removes the interaction using the specified arg (a. beging, 11.04.2022) /// Removes the interaction using the specified arg (a. beging, 11.04.2022)
/// </summary> /// </summary>
/// <param name="arg">The arg</param> /// <param name="arg">The arg</param>
private async Task RemoveInteraction(Guid 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.ConfirmButtonText = "Ja, wirklich!";
o.CancelButtonText = "Abbrechen"; o.CancelButtonText = "Abbrechen";
o.ShowMessageIcon = false; o.ShowMessageIcon = false;

View File

@@ -5,12 +5,24 @@
<PageTitle>Abgeschlossene Einarbeitungen</PageTitle> <PageTitle>Abgeschlossene Einarbeitungen</PageTitle>
<h2>Abgeschlossene Einarbeitungen</h2> <h2>Abgeschlossene Einarbeitungen</h2>
@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();
}
<hr />
<h5>@(filterList?.Count ?? 0) Einträge</h5>
<TextEdit TextChanged="FilterText_Changed" Placeholder="Suchen..." Debounce="true" DebounceInterval="150" />
@if (filterList?.Any() == true)
{ {
<hr />
<h5>@ProspectList.Count Einträge</h5>
<div class="row m-0"> <div class="row m-0">
<Repeater Items="@ProspectList"> <Repeater Items="@filterList">
<ProspectContainer Prospect="context" RemoveInteraction="RemoveInteraction"></ProspectContainer> <ProspectContainer Prospect="context" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater> </Repeater>
</div> </div>

View File

@@ -1,7 +1,6 @@
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages namespace FoodsharingSiegen.Server.Pages
@@ -22,6 +21,11 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Properties #region Private Properties
/// <summary>
/// Gets or sets the value of the filter text (ab)
/// </summary>
private string? FilterText { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the prospect list (ab) /// Gets or sets the value of the prospect list (ab)
/// </summary> /// </summary>
@@ -45,6 +49,19 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Private Method FilterText_Changed
/// <summary>
/// Filters the text changed using the specified filter text (a. beging, 08.02.2023)
/// </summary>
/// <param name="filterText">The filter text</param>
private void FilterText_Changed(string filterText)
{
FilterText = filterText;
}
#endregion
#region Private Method LoadProspects #region Private Method LoadProspects
/// <summary> /// <summary>

View File

@@ -6,13 +6,24 @@
<h2>Wartende Einarbeitungen</h2> <h2>Wartende Einarbeitungen</h2>
@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();
}
<hr />
<h5>@(filterList?.Count ?? 0) Einträge</h5>
<TextEdit TextChanged="FilterText_Changed" Placeholder="Suchen..." Debounce="true" DebounceInterval="150" />
@if (filterList?.Any() == true)
{ {
<hr />
<h5>@ProspectList.Count Einträge</h5>
<div class="text-center font-weight-bold">Bereits verifiziert, aber noch nicht abgeschlossen. Zum Beispiel, wenn noch der Druck-Ausweis fehlt o.ä.</div> <div class="text-center font-weight-bold">Bereits verifiziert, aber noch nicht abgeschlossen. Zum Beispiel, wenn noch der Druck-Ausweis fehlt o.ä.</div>
<div class="row m-0"> <div class="row m-0">
<Repeater Items="@ProspectList"> <Repeater Items="@filterList">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer> <ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater> </Repeater>
</div> </div>

View File

@@ -27,6 +27,11 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Properties #region Private Properties
/// <summary>
/// Gets or sets the value of the filter text (ab)
/// </summary>
private string? FilterText { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the interaction modal (ab) /// Gets or sets the value of the interaction modal (ab)
/// </summary> /// </summary>
@@ -36,14 +41,14 @@ namespace FoodsharingSiegen.Server.Pages
/// Gets or sets the value of the prospect list (ab) /// Gets or sets the value of the prospect list (ab)
/// </summary> /// </summary>
private List<Prospect>? ProspectList { get; set; } private List<Prospect>? ProspectList { get; set; }
/// <summary>
/// Gets or sets the value of the users (ab)
/// </summary>
private List<User>? Users { get; set; }
private AddProspectModal? ProspectModal { get; set; } private AddProspectModal? ProspectModal { get; set; }
/// <summary>
/// Gets or sets the value of the users (ab)
/// </summary>
private List<User>? Users { get; set; }
#endregion #endregion
#region Override OnAfterRenderAsync #region Override OnAfterRenderAsync
@@ -62,6 +67,32 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #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
/// <summary>
/// Filters the text changed using the specified filter text (a. beging, 08.02.2023)
/// </summary>
/// <param name="filterText">The filter text</param>
private void FilterText_Changed(string filterText)
{
FilterText = filterText;
}
#endregion
#region Private Method LoadProspects #region Private Method LoadProspects
/// <summary> /// <summary>
@@ -82,15 +113,6 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
protected override async Task OnInitializedAsync()
{
var getUsersR = await UserService.GetUsersAsync();
if (getUsersR.Success)
Users = getUsersR.Data;
await base.OnInitializedAsync();
}
#region Private Method OnAddInteraction #region Private Method OnAddInteraction
/// <summary> /// <summary>
@@ -105,6 +127,20 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Private Method OnUpdateProspect
/// <summary>
/// Ons the update prospect using the specified prospect (a. beging, 11.04.2022)
/// </summary>
/// <param name="prospect">The prospect</param>
private async Task OnUpdateProspect(Prospect prospect)
{
var updateProspectR = await ProspectService.UpdateAsync(prospect);
if (updateProspectR.Success) await LoadProspects();
}
#endregion
#region Private Method RemoveInteraction #region Private Method RemoveInteraction
/// <summary> /// <summary>
@@ -130,19 +166,5 @@ namespace FoodsharingSiegen.Server.Pages
} }
#endregion #endregion
#region Private Method OnUpdateProspect
/// <summary>
/// Ons the update prospect using the specified prospect (a. beging, 11.04.2022)
/// </summary>
/// <param name="prospect">The prospect</param>
private async Task OnUpdateProspect(Prospect prospect)
{
var updateProspectR = await ProspectService.UpdateAsync(prospect);
if (updateProspectR.Success) await LoadProspects();
}
#endregion
} }
} }