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)"
>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">
<Repeater Items="@ProspectList">
<Repeater Items="@filterList">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>

View File

@@ -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
{
/// <summary>
/// The prospects class (a. beging, 11.04.2022)
/// The prospects class (a. beging, 11.04.2022)
/// </summary>
public partial class Prospects
{
#region Dependencies (Injected)
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the user service (ab)
/// Gets or sets the value of the user service (ab)
/// </summary>
[Inject] public UserService UserService { get; set; } = null!;
#endregion
#region Public Properties
#region Private Properties
/// <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>
private AddInteractionModal? InteractionModal { get; set; }
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// Gets or sets the value of the prospect list (ab)
/// </summary>
private List<Prospect>? ProspectList { get; set; }
/// <summary>
/// Gets or sets the value of the prospect modal (ab)
/// Gets or sets the value of the prospect modal (ab)
/// </summary>
private AddProspectModal ProspectModal { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the users (ab)
/// Gets or sets the value of the users (ab)
/// </summary>
private List<User>? Users { get; set; }
@@ -53,7 +57,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnAfterRenderAsync
/// <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>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
@@ -69,23 +73,36 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 11.04.2022)
/// Ons the initialized (a. beging, 11.04.2022)
/// </summary>
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
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
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
/// <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>
/// <param name="arg">The arg</param>
private async Task OnAddInteraction(Interaction arg)
@@ -118,7 +135,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnAddProspect
/// <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>
/// <param name="arg">The arg</param>
private async Task OnAddProspect(Prospect arg)
@@ -132,7 +149,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnUpdateProspect
/// <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>
/// <param name="prospect">The prospect</param>
private async Task OnUpdateProspect(Prospect prospect)
@@ -146,12 +163,13 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method RemoveInteraction
/// <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>
/// <param name="arg">The arg</param>
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;

View File

@@ -5,12 +5,24 @@
<PageTitle>Abgeschlossene Einarbeitungen</PageTitle>
<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">
<Repeater Items="@ProspectList">
<Repeater Items="@filterList">
<ProspectContainer Prospect="context" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>

View File

@@ -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
/// <summary>
/// Gets or sets the value of the filter text (ab)
/// </summary>
private string? FilterText { get; set; }
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// </summary>
@@ -45,6 +49,19 @@ namespace FoodsharingSiegen.Server.Pages
#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
/// <summary>

View File

@@ -6,13 +6,24 @@
<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="row m-0">
<Repeater Items="@ProspectList">
<Repeater Items="@filterList">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>

View File

@@ -27,6 +27,11 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Properties
/// <summary>
/// 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>
@@ -36,14 +41,14 @@ namespace FoodsharingSiegen.Server.Pages
/// Gets or sets the value of the prospect list (ab)
/// </summary>
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; }
/// <summary>
/// Gets or sets the value of the users (ab)
/// </summary>
private List<User>? 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
/// <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
/// <summary>
@@ -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
/// <summary>
@@ -105,6 +127,20 @@ namespace FoodsharingSiegen.Server.Pages
#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
/// <summary>
@@ -130,19 +166,5 @@ namespace FoodsharingSiegen.Server.Pages
}
#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
}
}