Darstellung der Prospects fragmentiert

This commit is contained in:
Andre Beging
2023-02-07 23:13:09 +01:00
parent 1b59a9461b
commit df40e2b769
12 changed files with 317 additions and 39 deletions

View File

@@ -0,0 +1,9 @@
using FoodsharingSiegen.Contracts.Entity;
namespace FoodsharingSiegen.Contracts.Model
{
/// <summary>
/// The get prospects parameter
/// </summary>
public record GetProspectsParameter(List<InteractionType>? MustHaveInteractions = null, List<InteractionType>? CannotHaveInteractions = null);
}

View File

@@ -18,7 +18,7 @@
flex-grow: 1; flex-grow: 1;
max-width: 480px; max-width: 480px;
border: 1px solid #533a20; border: 1px solid #533a20;
border-radius: 15px; border-radius: 7px;
margin: 5px; margin: 5px;
padding: 16px; padding: 16px;
} }

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts; using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Auth; using FoodsharingSiegen.Server.Auth;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -103,12 +104,18 @@ namespace FoodsharingSiegen.Server.Data.Service
/// Gets the users (a. beging, 01.04.2022) /// Gets the users (a. beging, 01.04.2022)
/// </summary> /// </summary>
/// <returns>A task containing an operation result of list prospect</returns> /// <returns>A task containing an operation result of list prospect</returns>
public async Task<OperationResult<List<Prospect>>> GetProspectsAsync(InteractionType? filterType = null) public async Task<OperationResult<List<Prospect>>> GetProspectsAsync(GetProspectsParameter parameter)
{ {
try try
{ {
var prospectsQuery = Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).AsQueryable(); var prospectsQuery = Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).AsQueryable();
if(filterType != null) prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => i.Type == filterType));
if(parameter.MustHaveInteractions != null && parameter.MustHaveInteractions.Any())
prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => parameter.MustHaveInteractions.Contains(i.Type)));
if(parameter.CannotHaveInteractions != null && parameter.CannotHaveInteractions.Any())
prospectsQuery = prospectsQuery.Where(x => x.Interactions.All(i => !parameter.CannotHaveInteractions.Contains(i.Type)));
var prospects = await prospectsQuery.ToListAsync(); var prospects = await prospectsQuery.ToListAsync();
return new OperationResult<List<Prospect>>(prospects); return new OperationResult<List<Prospect>>(prospects);

View File

@@ -1,16 +1,10 @@
@page "/" @page "/"
@page "/prospect" @page "/prospect"
@page "/prospects" @page "/prospects"
@using FoodsharingSiegen.Server.Dialogs
@using FoodsharingSiegen.Server.Controls
@using FoodsharingSiegen.Contracts.Entity
@using FoodsharingSiegen.Contracts.Helper
@using FoodsharingSiegen.Server.BaseClasses
@inherits FsBase @inherits FsBase
<PageTitle>Einarbeitungen</PageTitle> <PageTitle>Aktuelle Einarbeitungen</PageTitle>
<h2>Aktuelle Einarbeitungen</h2> <h2>Aktuelle Einarbeitungen</h2>
<Button <Button
@@ -19,35 +13,17 @@
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 activeProspects = ProspectList?.Where(x => x.Interactions.All(i => i.Type != InteractionType.Complete)); @if (ProspectList?.Any() == true)
}
@if (activeProspects?.Any() == true)
{ {
<hr /> <hr />
<h3>Aktuell:</h3> <h5>@ProspectList.Count Einträge</h5>
<div class="row m-0"> <div class="row m-0">
<Repeater Items="@activeProspects"> <Repeater Items="@ProspectList">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer> <ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater> </Repeater>
</div> </div>
} }
@{
var completedProspects = ProspectList?.Where(x => x.Interactions.Any(i => i.Type == InteractionType.Complete));
}
@if (completedProspects?.Any() == true)
{
<hr />
<h3>Abgeschlossen:</h3>
<div class="row m-0">
<Repeater Items="@completedProspects">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>
}
<AddProspectModal @ref="ProspectModal" OnAdd="OnAddProspect" OnUpdate="OnUpdateProspect"></AddProspectModal> <AddProspectModal @ref="ProspectModal" OnAdd="OnAddProspect" OnUpdate="OnUpdateProspect"></AddProspectModal>
<AddInteractionModal @ref="InteractionModal" OnAdd="OnAddInteraction" Users="Users"></AddInteractionModal> <AddInteractionModal @ref="InteractionModal" OnAdd="OnAddInteraction" Users="Users"></AddInteractionModal>

View File

@@ -1,5 +1,6 @@
using Blazorise; using Blazorise;
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs; using FoodsharingSiegen.Server.Dialogs;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@@ -88,7 +89,11 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary> /// </summary>
private async Task LoadProspects() private async Task LoadProspects()
{ {
var prospectsR = await ProspectService.GetProspectsAsync(); var parameter = new GetProspectsParameter
{
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete, InteractionType.Verify }
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data; if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);

View File

@@ -0,0 +1,17 @@
@page "/done"
@inherits FsBase
<PageTitle>Abgeschlossene Einarbeitungen</PageTitle>
<h2>Abgeschlossene Einarbeitungen</h2>
@if (ProspectList?.Any() == true)
{
<hr />
<h5>@ProspectList.Count Einträge</h5>
<div class="row m-0">
<Repeater Items="@ProspectList">
<ProspectContainer Prospect="context" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>
}

View File

@@ -0,0 +1,93 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The prospects done class (a. beging, 07.02.2023)
/// </summary>
public partial class ProspectsTodo
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// </summary>
private List<Prospect>? ProspectList { get; set; }
#endregion
#region Override OnAfterRenderAsync
/// <summary>
/// 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)
{
if (firstRender)
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
}
#endregion
#region Private Method LoadProspects
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter
{
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete },
MustHaveInteractions = new List<InteractionType> { InteractionType.Verify }
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged);
}
#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
}
}

View File

@@ -0,0 +1,19 @@
@page "/todo"
@inherits FsBase
<PageTitle>Wartende Einarbeitungen</PageTitle>
<h2>Wartende Einarbeitungen</h2>
@if (ProspectList?.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">
<ProspectContainer Prospect="context" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>
}

View File

@@ -0,0 +1,89 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The prospects done class (a. beging, 07.02.2023)
/// </summary>
public partial class ProspectsDone
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// </summary>
private List<Prospect>? ProspectList { get; set; }
#endregion
#region Override OnAfterRenderAsync
/// <summary>
/// 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)
{
if (firstRender)
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
}
#endregion
#region Private Method LoadProspects
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter {MustHaveInteractions = new List<InteractionType> { InteractionType.Complete }};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged);
}
#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
}
}

View File

@@ -1,4 +1,4 @@
<nav class="flex-column"> <nav class="flex-column">
<div class="nav-logo"></div> <div class="nav-logo"></div>
<div class="row px-3"> <div class="row px-3">
<div class="col"> <div class="col">
@@ -18,14 +18,29 @@
</div> </div>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="fas fa-tasks mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Übersicht <span class="fas fa-user-plus mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Neue Foodsaver
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3 mt-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="users" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="todo" Match="NavLinkMatch.All">
<span class="fas fa-users mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Benutzer <span class="fas fa-user-clock mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> ToDo
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="done" Match="NavLinkMatch.All">
<span class="fas fa-user-shield mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Abgeschlossen
</NavLink> </NavLink>
</div> </div>
@if (CurrentUser.IsAdmin())
{
<div class="nav-item px-3 mt-3">
<NavLink class="nav-link" href="users" Match="NavLinkMatch.All">
<span class="fas fa-users mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Benutzer
</NavLink>
</div>
}
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="audit" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="audit" Match="NavLinkMatch.All">
<span class="fa-solid fa-clock-rotate-left mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Aktivitäten <span class="fa-solid fa-clock-rotate-left mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Aktivitäten

View File

@@ -0,0 +1,43 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.Auth;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Shared
{
/// <summary>
/// The nav menu class (a. beging, 07.02.2023)
/// </summary>
public partial class NavMenu
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the auth service (ab)
/// </summary>
[Inject] protected AuthService AuthService { get; set; } = null!;
#endregion
#region Private Properties
/// <summary>
/// Gets the value of the current user (ab)
/// </summary>
private User CurrentUser => AuthService.User ?? new User();
#endregion
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 07.02.2023)
/// </summary>
protected override async Task OnInitializedAsync()
{
await AuthService.Initialize();
await base.OnInitializedAsync();
}
#endregion
}
}

View File

@@ -11,3 +11,8 @@
@using Blazorise @using Blazorise
@using Blazorise.DataGrid @using Blazorise.DataGrid
@using Blazorise.Components @using Blazorise.Components
@using FoodsharingSiegen.Server.BaseClasses
@using FoodsharingSiegen.Server.Dialogs
@using FoodsharingSiegen.Server.Controls
@using FoodsharingSiegen.Contracts.Entity
@using FoodsharingSiegen.Contracts.Helper