Data loading update, prospect container styling

This commit is contained in:
Andre Beging
2025-03-27 16:16:48 +01:00
parent bb5ec71539
commit 572a35fd3f
11 changed files with 137 additions and 125 deletions

View File

@@ -64,6 +64,12 @@ namespace FoodsharingSiegen.Server.BaseClasses
#endregion #endregion
#region Private Fields
private bool _dataInitialized;
#endregion
#region Override OnInitializedAsync #region Override OnInitializedAsync
/// <summary> /// <summary>
@@ -77,6 +83,34 @@ namespace FoodsharingSiegen.Server.BaseClasses
#endregion #endregion
#region Override SetParametersAsync
/// <inheritdoc />
public override async Task SetParametersAsync(ParameterView parameters)
{
parameters.SetParameterProperties(this);
if (!_dataInitialized)
{
_dataInitialized = true;
await InitializeDataAsync();
}
// Da die Parameter bereits gesetzt wurden, kann die Basisklasse am Ende aufgerufen werden.
await base.SetParametersAsync(ParameterView.Empty);
}
#endregion
#region Protected Method InitializeDataAsync
/// <summary>
/// Initialize data here, Database Actions belong here
/// </summary>
protected virtual async Task InitializeDataAsync() => await Task.CompletedTask;
#endregion
#region Protected Method RefreshState #region Protected Method RefreshState
/// <summary> /// <summary>

View File

@@ -11,32 +11,36 @@
<th class="text-center align-top pr-2"> <th class="text-center align-top pr-2">
<i class="@IconClass"></i> <i class="@IconClass"></i>
</th> </th>
<th class="pr-2 align-top">@Caption:</th> <th class="pr-2 align-top" style="white-space: nowrap;">@Caption:</th>
<td class="align-top"> <td class="align-top d-flex flex-column">
@if (Interactions.Count > 0) @if (Interactions.Count > 0)
{ {
foreach (var interaction in Interactions) foreach (var interaction in Interactions)
{ {
<div> <div style="padding-bottom: .5rem;">
<div style="white-space: nowrap;">
<span title="@interaction.User.Memo">@interaction.User.Name</span> (@interaction.Date.ToShortDateString()) <span title="@interaction.User.Memo">@interaction.User.Name</span> (@interaction.Date.ToShortDateString())
@if ((Prospect is not { Complete: true } || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
{
<span>&nbsp;<a href=""><i class="fa-solid fa-square-xmark" @onclick="async () => await RemoveClick.InvokeAsync(interaction.Id)" @onclick:preventDefault></i></a></span>
}
</div>
@if (!string.IsNullOrWhiteSpace(interaction.Info)) @if (!string.IsNullOrWhiteSpace(interaction.Info))
{ {
<span>(<i>@interaction.Info</i>)</span> <span>(<i>@interaction.Info</i>)</span>
} }
@if ((Prospect is not {Complete: true } || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
{
<span>&nbsp;<a href=""><i class="fa-solid fa-square-xmark" @onclick="async () => await RemoveClick.InvokeAsync(interaction.Id)" @onclick:preventDefault></i></a></span>
}
</div> </div>
} }
} }
@if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction) @if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction)
{ {
if (Multiple) ButtonText = "+"; if (Multiple) ButtonIconClass = "fa-solid fa-plus";
<Button Size="Size.Small" Clicked="AddClick">@ButtonText</Button> <div class="m-auto">
<Button Size="Size.Small" Clicked="AddClick"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
</div>
} }
</td> </td>
</tr> </tr>

View File

@@ -26,7 +26,7 @@ namespace FoodsharingSiegen.Server.Controls
/// Gets or sets the value of the button text (ab) /// Gets or sets the value of the button text (ab)
/// </summary> /// </summary>
[Parameter] [Parameter]
public string? ButtonText { get; set; } public string? ButtonIconClass { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of the caption (ab) /// Gets or sets the value of the caption (ab)

View File

@@ -32,7 +32,7 @@
} }
<table> <table style="width: 100%;">
<InteractionRow <InteractionRow
Prospect="Prospect" Prospect="Prospect"
@@ -41,7 +41,7 @@
AddClick="() => AddInteraction(InteractionType.Welcome)" AddClick="() => AddInteraction(InteractionType.Welcome)"
RemoveClick="@RemoveInteraction" RemoveClick="@RemoveInteraction"
Caption="Begrüßung" Caption="Begrüßung"
ButtonText="Abhaken" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-handshake-simple"> IconClass="fa-solid fa-handshake-simple">
</InteractionRow> </InteractionRow>
@@ -54,18 +54,24 @@
Caption="Einführungen" Caption="Einführungen"
Multiple="true" Multiple="true"
Minimum="3" Minimum="3"
ButtonText="Hinzufügen" ButtonIconClass="fa-solid fa-plus"
IconClass="fa-solid fa-basket-shopping"> IconClass="fa-solid fa-basket-shopping">
</InteractionRow> </InteractionRow>
<tr>
<td colspan="3">
<hr style="margin: 10px 0;">
</td>
</tr>
<InteractionRow <InteractionRow
Prospect="Prospect" Prospect="Prospect"
Type="InteractionType.IdCheck" Type="InteractionType.IdCheck"
AllowAddInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" AllowAddInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)"
AddClick="() => AddInteraction(InteractionType.IdCheck)" AddClick="() => AddInteraction(InteractionType.IdCheck)"
RemoveClick="@RemoveInteraction" RemoveClick="@RemoveInteraction"
Caption="Perso prüfen" Caption="Perso checken"
ButtonText="Abhaken" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-magnifying-glass"> IconClass="fa-solid fa-magnifying-glass">
</InteractionRow> </InteractionRow>
@@ -76,7 +82,7 @@
AddClick="() => AddInteraction(InteractionType.PrintPass)" AddClick="() => AddInteraction(InteractionType.PrintPass)"
RemoveClick="@RemoveInteraction" RemoveClick="@RemoveInteraction"
Caption="FS-Ausweis (print)" Caption="FS-Ausweis (print)"
ButtonText="Abhaken" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-id-card"> IconClass="fa-solid fa-id-card">
</InteractionRow> </InteractionRow>
@@ -87,10 +93,16 @@
AddClick="() => AddInteraction(InteractionType.Verify)" AddClick="() => AddInteraction(InteractionType.Verify)"
RemoveClick="@RemoveInteraction" RemoveClick="@RemoveInteraction"
Caption="Verifizieren" Caption="Verifizieren"
ButtonText="Abhaken" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-user-check"> IconClass="fa-solid fa-user-check">
</InteractionRow> </InteractionRow>
<tr>
<td colspan="3">
<hr style="margin: 10px 0;">
</td>
</tr>
<InteractionRow <InteractionRow
Prospect="Prospect" Prospect="Prospect"
AllowAddInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" AllowAddInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)"
@@ -98,7 +110,7 @@
AddClick="() => AddInteraction(InteractionType.Complete)" AddClick="() => AddInteraction(InteractionType.Complete)"
RemoveClick="@RemoveInteraction" RemoveClick="@RemoveInteraction"
Caption="Fertig" Caption="Fertig"
ButtonText="Abhaken" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-flag-checkered"> IconClass="fa-solid fa-flag-checkered">
</InteractionRow> </InteractionRow>

View File

@@ -9,16 +9,17 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary> /// </summary>
public partial class AuditView public partial class AuditView
{ {
#region Dependencies (Injected) #region Dependencies
/// <summary> /// <summary>
/// Gets or sets the value of the audit service (ab) /// Gets or sets the value of the audit service (ab)
/// </summary> /// </summary>
[Inject] public AuditService? AuditService { get; set; } [Inject]
public AuditService? AuditService { get; set; }
#endregion #endregion
#region Public Properties #region Private Properties
/// <summary> /// <summary>
/// Gets or sets the value of the audits (ab) /// Gets or sets the value of the audits (ab)
@@ -27,18 +28,14 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Override OnInitializedAsync #region Override InitializeDataAsync
/// <summary> /// <inheritdoc />
/// Ons the initialized (a. beging, 23.05.2022) protected override async Task InitializeDataAsync()
/// </summary>
protected override async Task OnInitializedAsync()
{ {
var loadR = await AuditService?.Load(100)!; var loadR = await AuditService?.Load(100)!;
if (loadR.Success) if (loadR.Success)
Audits = loadR.Data; Audits = loadR.Data;
await base.OnInitializedAsync();
} }
#endregion #endregion

View File

@@ -11,16 +11,13 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary> /// </summary>
public partial class Profile public partial class Profile
{ {
#region Dependencies (Injected) #region Dependencies
#region Dependencies (Injected)
/// <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; } [Inject]
public UserService? UserService { get; set; }
#endregion
#endregion #endregion
@@ -51,7 +48,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <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)
{ {
if(firstRender) await ValidationsRef?.ValidateAll()!; if (firstRender) await ValidationsRef?.ValidateAll()!;
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
} }
@@ -66,7 +63,6 @@ namespace FoodsharingSiegen.Server.Pages
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
User = CurrentUser.Clone(); User = CurrentUser.Clone();
} }
#endregion #endregion

View File

@@ -16,12 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
/// <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
@@ -54,34 +56,18 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Override OnAfterRenderAsync #region Override InitializeDataAsync
/// <summary> /// <inheritdoc />
/// Ons the after render using the specified first render (a. beging, 11.04.2022) protected override async Task InitializeDataAsync()
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) // Load prospects
await LoadProspects(); await LoadProspects();
await base.OnAfterRenderAsync(firstRender); // Load users
}
#endregion
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 11.04.2022)
/// </summary>
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();
} }
#endregion #endregion
@@ -108,7 +94,7 @@ namespace FoodsharingSiegen.Server.Pages
{ {
var parameter = new GetProspectsParameter var parameter = new GetProspectsParameter
{ {
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete, InteractionType.Verify } CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify]
}; };
var prospectsR = await ProspectService.GetProspectsAsync(parameter); var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data; if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

@@ -15,7 +15,8 @@ namespace FoodsharingSiegen.Server.Pages
/// <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!;
#endregion #endregion
@@ -33,18 +34,12 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Override OnAfterRenderAsync #region Override InitializeDataAsync
/// <summary> /// <inheritdoc />
/// Ons the after render using the specified first render (a. beging, 11.04.2022) protected override async Task InitializeDataAsync()
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender)
await LoadProspects(); await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
} }
#endregion #endregion
@@ -69,7 +64,7 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary> /// </summary>
private async Task LoadProspects() private async Task LoadProspects()
{ {
var parameter = new GetProspectsParameter { MustHaveInteractions = new List<InteractionType> { InteractionType.Complete } }; var parameter = new GetProspectsParameter { MustHaveInteractions = new() { InteractionType.Complete } };
var prospectsR = await ProspectService.GetProspectsAsync(parameter); var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data; if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

@@ -16,12 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
/// <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
@@ -51,31 +53,18 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Override OnAfterRenderAsync #region Override InitializeDataAsync
/// <summary> /// <inheritdoc />
/// Ons the after render using the specified first render (a. beging, 11.04.2022) protected override async Task InitializeDataAsync()
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) // Load prospects
await LoadProspects(); await LoadProspects();
await base.OnAfterRenderAsync(firstRender); // Load users
}
#endregion
#region Override 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();
} }
#endregion #endregion
@@ -102,8 +91,8 @@ namespace FoodsharingSiegen.Server.Pages
{ {
var parameter = new GetProspectsParameter var parameter = new GetProspectsParameter
{ {
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete }, CannotHaveInteractions = [InteractionType.Complete],
MustHaveInteractions = new List<InteractionType> { InteractionType.Verify } MustHaveInteractions = [InteractionType.Verify]
}; };
var prospectsR = await ProspectService.GetProspectsAsync(parameter); var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data; if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

@@ -19,7 +19,8 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary> Gets or sets the user service. </summary> /// <summary> Gets or sets the user service. </summary>
/// <value> The user service. </value> /// <value> The user service. </value>
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
[Inject] public UserService UserService { get; set; } = null!; [Inject]
public UserService UserService { get; set; } = null!;
#endregion #endregion
@@ -57,18 +58,12 @@ namespace FoodsharingSiegen.Server.Pages
#endregion #endregion
#region Override OnAfterRenderAsync #region Override InitializeDataAsync
/// <summary> /// <inheritdoc />
/// Ons the after render using the specified first render (a. beging, 01.04.2022) protected override async Task InitializeDataAsync()
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender)
await LoadUsers(); await LoadUsers();
await base.OnAfterRenderAsync(firstRender);
} }
#endregion #endregion

View File

@@ -8,6 +8,10 @@ h1:focus {
outline: none; outline: none;
} }
hr {
height: initial !important;
}
a, .btn-link { a, .btn-link {
color: green; color: green;
} }