Add "All" prospects view and refine filtering logic
Introduced a new "All" prospects page for admins to view and manage all prospects. Removed unused "Users" list and related logic from code. Updated filters to support the new "All" state and adjusted navigation to include the new page.
This commit is contained in:
@@ -92,6 +92,8 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
|
||||
public enum ProspectStateFilter
|
||||
{
|
||||
All = 0,
|
||||
|
||||
OnBoarding = 10,
|
||||
|
||||
Verification = 20,
|
||||
|
||||
@@ -40,19 +40,19 @@
|
||||
<i class="fa-solid fa-filter"></i> Suchfilter
|
||||
</div>
|
||||
<div class="card-body" style="padding: .5rem;">
|
||||
@if (StateFilter == ProspectStateFilter.OnBoarding)
|
||||
@if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.All)
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.WithoutStepInBriefing" CheckedChanged="WithoutStepInBriefingChangedAsync">Ohne @AppSettings.Terms.StepInName</Switch>
|
||||
</div>
|
||||
}
|
||||
@if (StateFilter == ProspectStateFilter.Verification)
|
||||
@if (StateFilter is ProspectStateFilter.Verification or ProspectStateFilter.All)
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.WithoutIdCheck" CheckedChanged="WithoutIdCheckChangedAsync">Perso noch nicht geprüft</Switch>
|
||||
</div>
|
||||
}
|
||||
@if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification)
|
||||
@if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification or ProspectStateFilter.All)
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.NoActivity" CheckedChanged="NoActivityChangedAsync">Lange keine Aktivität (6 Monate)</Switch>
|
||||
|
||||
@@ -36,11 +36,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
/// </summary>
|
||||
private List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the users (ab)
|
||||
/// </summary>
|
||||
private List<User>? Users { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
@@ -50,11 +45,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
// Load prospects
|
||||
await LoadProspects();
|
||||
|
||||
// Load users
|
||||
var getUsersR = await UserService.GetUsersAsync();
|
||||
if (getUsersR.Success)
|
||||
Users = getUsersR.Data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
21
FoodsharingSiegen.Server/Pages/ProspectsAll.razor
Normal file
21
FoodsharingSiegen.Server/Pages/ProspectsAll.razor
Normal file
@@ -0,0 +1,21 @@
|
||||
@page "/all"
|
||||
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
@inherits FsBase
|
||||
|
||||
<PageTitle>Freischalten - @AppSettings.Terms.Title</PageTitle>
|
||||
|
||||
<h2>Freischalten</h2>
|
||||
|
||||
@{
|
||||
var filterList = ProspectList.ApplyFilter(Filter);
|
||||
}
|
||||
|
||||
<hr/>
|
||||
<ProspectFilterControl @bind-Filter="Filter" StateFilter="ProspectStateFilter.All"></ProspectFilterControl>
|
||||
<hr />
|
||||
<ProspectGrid
|
||||
Prospects="filterList"
|
||||
OnDataChanged="@LoadProspects"
|
||||
StateFilter="ProspectStateFilter.All">
|
||||
</ProspectGrid>
|
||||
108
FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs
Normal file
108
FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// The prospects done class (a. beging, 07.02.2023)
|
||||
/// </summary>
|
||||
public partial class ProspectsAll
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public UserService UserService { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private ProspectFilter Filter { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect list (ab)
|
||||
/// </summary>
|
||||
private List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task InitializeDataAsync()
|
||||
{
|
||||
// Load prospects
|
||||
await LoadProspects();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method LoadProspects
|
||||
|
||||
/// <summary>
|
||||
/// Loads the prospects (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
private async Task LoadProspects()
|
||||
{
|
||||
var parameter = new GetProspectsParameter();
|
||||
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
|
||||
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#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>
|
||||
/// 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 =>
|
||||
{
|
||||
o.ConfirmButtonText = "Ja, wirklich!";
|
||||
o.CancelButtonText = "Abbrechen";
|
||||
o.ShowMessageIcon = false;
|
||||
});
|
||||
|
||||
if (confirm)
|
||||
{
|
||||
await ProspectService.RemoveInteraction(arg);
|
||||
await LoadProspects();
|
||||
}
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -36,11 +36,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
/// </summary>
|
||||
private List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the users (ab)
|
||||
/// </summary>
|
||||
private List<User>? Users { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
@@ -50,11 +45,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
// Load prospects
|
||||
await LoadProspects();
|
||||
|
||||
// Load users
|
||||
var getUsersR = await UserService.GetUsersAsync();
|
||||
if (getUsersR.Success)
|
||||
Users = getUsersR.Data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<hr/>
|
||||
<div class="nav-item px-3">
|
||||
<div @onclick="NavLinkClickedAsync">
|
||||
<NavLink class="nav-link" href="done" Match="NavLinkMatch.All">
|
||||
<NavLink class="nav-link" href="all" Match="NavLinkMatch.All">
|
||||
<span class="fas fa-user-shield mr-2" aria-hidden="true" style="font-size: 1.4em;"></span> Alle (Admin)
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user