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
#region Private Fields
private bool _dataInitialized;
#endregion
#region Override OnInitializedAsync
/// <summary>
@@ -77,6 +83,34 @@ namespace FoodsharingSiegen.Server.BaseClasses
#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
/// <summary>

View File

@@ -11,32 +11,36 @@
<th class="text-center align-top pr-2">
<i class="@IconClass"></i>
</th>
<th class="pr-2 align-top">@Caption:</th>
<td class="align-top">
<th class="pr-2 align-top" style="white-space: nowrap;">@Caption:</th>
<td class="align-top d-flex flex-column">
@if (Interactions.Count > 0)
{
foreach (var interaction in Interactions)
{
<div>
<span title="@interaction.User.Memo">@interaction.User.Name</span> (@interaction.Date.ToShortDateString())
<div style="padding-bottom: .5rem;">
<div style="white-space: nowrap;">
<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))
{
<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>
}
}
@if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction)
{
if (Multiple) ButtonText = "+";
<Button Size="Size.Small" Clicked="AddClick">@ButtonText</Button>
if (Multiple) ButtonIconClass = "fa-solid fa-plus";
<div class="m-auto">
<Button Size="Size.Small" Clicked="AddClick"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
</div>
}
</td>
</tr>

View File

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

View File

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

View File

@@ -5,40 +5,37 @@ using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The audit view class (a. beging, 23.05.2022)
/// The audit view class (a. beging, 23.05.2022)
/// </summary>
public partial class AuditView
{
#region Dependencies (Injected)
#region Dependencies
/// <summary>
/// Gets or sets the value of the audit service (ab)
/// Gets or sets the value of the audit service (ab)
/// </summary>
[Inject] public AuditService? AuditService { get; set; }
[Inject]
public AuditService? AuditService { get; set; }
#endregion
#region Public Properties
#region Private Properties
/// <summary>
/// Gets or sets the value of the audits (ab)
/// Gets or sets the value of the audits (ab)
/// </summary>
private List<Audit>? Audits { get; set; }
#endregion
#region Override OnInitializedAsync
#region Override InitializeDataAsync
/// <summary>
/// Ons the initialized (a. beging, 23.05.2022)
/// </summary>
protected override async Task OnInitializedAsync()
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
var loadR = await AuditService?.Load(100)!;
if (loadR.Success)
Audits = loadR.Data;
await base.OnInitializedAsync();
}
#endregion

View File

@@ -7,37 +7,34 @@ using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The profile class (a. beging, 21.05.2022)
/// The profile class (a. beging, 21.05.2022)
/// </summary>
public partial class Profile
{
#region Dependencies (Injected)
#region Dependencies (Injected)
#region Dependencies
/// <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; }
#endregion
[Inject]
public UserService? UserService { get; set; }
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the password modal (ab)
/// Gets or sets the value of the password modal (ab)
/// </summary>
private SetPasswordModal? PasswordModal { get; set; }
/// <summary>
/// Gets or sets the value of the user (ab)
/// Gets or sets the value of the user (ab)
/// </summary>
private User User { get; set; } = new();
/// <summary>
/// Gets or sets the value of the validations ref (ab)
/// Gets or sets the value of the validations ref (ab)
/// </summary>
private Validations? ValidationsRef { get; set; }
@@ -46,12 +43,12 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnAfterRenderAsync
/// <summary>
/// Ons the after render using the specified first render (a. beging, 21.05.2022)
/// Ons the after render using the specified first render (a. beging, 21.05.2022)
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender) await ValidationsRef?.ValidateAll()!;
if (firstRender) await ValidationsRef?.ValidateAll()!;
await base.OnAfterRenderAsync(firstRender);
}
@@ -60,13 +57,12 @@ namespace FoodsharingSiegen.Server.Pages
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 21.05.2022)
/// Ons the initialized (a. beging, 21.05.2022)
/// </summary>
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
User = CurrentUser.Clone();
}
#endregion
@@ -74,7 +70,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method ChangePassword
/// <summary>
/// Changes the password (a. beging, 23.05.2022)
/// Changes the password (a. beging, 23.05.2022)
/// </summary>
private async Task ChangePassword()
{
@@ -86,7 +82,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method OnPasswordSet
/// <summary>
/// Ons the password set using the specified arg (a. beging, 23.05.2022)
/// Ons the password set using the specified arg (a. beging, 23.05.2022)
/// </summary>
/// <param name="arg">The arg</param>
private async Task OnPasswordSet(User arg)
@@ -103,7 +99,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method RemoveAccount
/// <summary>
/// Removes the account (a. beging, 23.05.2022)
/// Removes the account (a. beging, 23.05.2022)
/// </summary>
private async Task RemoveAccount()
{
@@ -115,7 +111,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method SaveProfile
/// <summary>
/// Saves the profile (a. beging, 21.05.2022)
/// Saves the profile (a. beging, 21.05.2022)
/// </summary>
private async Task SaveProfile()
{

View File

@@ -16,12 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
[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!;
[Inject]
public UserService UserService { get; set; } = null!;
#endregion
@@ -54,34 +56,18 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
#region Override OnAfterRenderAsync
#region Override InitializeDataAsync
/// <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)
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
if (firstRender)
await LoadProspects();
// Load prospects
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
}
#endregion
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 11.04.2022)
/// </summary>
protected override async Task OnInitializedAsync()
{
// Load users
var getUsersR = await UserService.GetUsersAsync();
if (getUsersR.Success)
Users = getUsersR.Data;
await base.OnInitializedAsync();
}
#endregion
@@ -108,7 +94,7 @@ namespace FoodsharingSiegen.Server.Pages
{
var parameter = new GetProspectsParameter
{
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete, InteractionType.Verify }
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify]
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

@@ -15,7 +15,8 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
[Inject]
public ProspectService ProspectService { get; set; } = null!;
#endregion
@@ -33,18 +34,12 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
#region Override OnAfterRenderAsync
#region Override InitializeDataAsync
/// <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)
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
if (firstRender)
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
await LoadProspects();
}
#endregion
@@ -69,7 +64,7 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
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);
if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

@@ -16,12 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject] public ProspectService ProspectService { get; set; } = null!;
[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!;
[Inject]
public UserService UserService { get; set; } = null!;
#endregion
@@ -51,31 +53,18 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
#region Override OnAfterRenderAsync
#region Override InitializeDataAsync
/// <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)
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
if (firstRender)
await LoadProspects();
// Load prospects
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
}
#endregion
#region Override OnInitializedAsync
protected override async Task OnInitializedAsync()
{
// Load users
var getUsersR = await UserService.GetUsersAsync();
if (getUsersR.Success)
Users = getUsersR.Data;
await base.OnInitializedAsync();
}
#endregion
@@ -102,8 +91,8 @@ namespace FoodsharingSiegen.Server.Pages
{
var parameter = new GetProspectsParameter
{
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete },
MustHaveInteractions = new List<InteractionType> { InteractionType.Verify }
CannotHaveInteractions = [InteractionType.Complete],
MustHaveInteractions = [InteractionType.Verify]
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;

View File

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

View File

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