Add new filters and refactor InteractionDialog handling

Introduced new filters for prospects: "WithoutIdCheck" and "NoActivity" with associated UI controls. Refactored `InteractionDialog.ShowAsync` to use a new parameter record for cleaner code and better extensibility. These changes enhance usability and maintainability by providing additional filtering options and streamlining dialog interactions.
This commit is contained in:
Andre Beging
2025-03-28 20:07:12 +01:00
parent aadf88db2b
commit 350e2003ca
5 changed files with 82 additions and 48 deletions

View File

@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Dialogs
{
public record InteractionDialogParameter(InteractionType Type, Guid ProspectId, string HeaderText, Func<Task> OnSuccess);
public partial class InteractionDialog : FsBase
{
#region Dependencies
@@ -43,40 +45,16 @@ namespace FoodsharingSiegen.Server.Dialogs
#region Public Method ShowAsync
/// <summary>
/// Displays a modal dialog for adding an interaction with configurable settings based on the interaction type and associated prospect ID.
/// Displays the InteractionDialog modal with the specified parameters.
/// </summary>
/// <param name="modalService">
/// The modal service used to display the modal dialog.
/// </param>
/// <param name="onSuccess">
/// Callback to be invoked upon successful addition of an interaction
/// </param>
/// <param name="type">
/// The type of interaction to be added.
/// </param>
/// <param name="prospectId">
/// The unique identifier of the prospect associated with the interaction.
/// </param>
/// <param name="modalService">The modal service used to display the dialog.</param>
/// <param name="parameter">The parameters required for the dialog, including type, prospect ID, header text, and success callback.</param>
/// <returns>
/// A task representing the asynchronous operation of showing the modal dialog.
/// A task representing the asynchronous operation.
/// </returns>
public static async Task ShowAsync(IModalService modalService, Func<Task> onSuccess, InteractionType type, Guid prospectId)
public static async Task ShowAsync(IModalService modalService, InteractionDialogParameter parameter)
{
var headerText = type switch
{
InteractionType.EinAb => "Einführung eintragen",
InteractionType.Welcome => "Begrüßung eintragen",
InteractionType.IdCheck => "Ausweisprüfung eintragen",
InteractionType.PrintPass => "FS-Ausweis (Print)",
InteractionType.PdfPass => "FS-Ausweis (PDF)",
InteractionType.Verify => "Verifizierung eintragen",
InteractionType.Complete => "Als fertig markieren",
InteractionType.StepInBriefing => $"Neulingstreffen absolviert",
InteractionType.ReleasedForVerification => "Zur Verifizierung freigegeben",
_ => "Neuer Eintrag"
};
var showInfo = type switch
var showInfo = parameter.Type switch
{
InteractionType.EinAb => true,
InteractionType.Complete => true,
@@ -87,21 +65,21 @@ namespace FoodsharingSiegen.Server.Dialogs
_ => false
};
var infoName = type switch
var infoName = parameter.Type switch
{
InteractionType.EinAb => "Welcher Betrieb?",
InteractionType.ReleasedForVerification => "Hinweis",
_ => "Kommentar"
};
var showAlert = type switch
var showAlert = parameter.Type switch
{
InteractionType.EinAb => true,
InteractionType.IdCheck => true,
_ => false
};
var showNotNeeded = type switch
var showNotNeeded = parameter.Type switch
{
InteractionType.PrintPass => true,
InteractionType.PdfPass => true,
@@ -110,19 +88,19 @@ namespace FoodsharingSiegen.Server.Dialogs
var interaction = new Interaction
{
Type = type,
Type = parameter.Type,
Date = DateTime.UtcNow,
ProspectID = prospectId
ProspectID = parameter.ProspectId
};
await modalService.Show<InteractionDialog>(headerText, parameter =>
await modalService.Show<InteractionDialog>(parameter.HeaderText, p =>
{
parameter.Add(nameof(Interaction), interaction);
parameter.Add(nameof(ShowInfo), showInfo);
parameter.Add(nameof(InfoName), infoName);
parameter.Add(nameof(ShowAlert), showAlert);
parameter.Add(nameof(ShowNotNeeded), showNotNeeded);
parameter.Add(nameof(OnSuccess), onSuccess);
p.Add(nameof(Interaction), interaction);
p.Add(nameof(ShowInfo), showInfo);
p.Add(nameof(InfoName), infoName);
p.Add(nameof(ShowAlert), showAlert);
p.Add(nameof(ShowNotNeeded), showNotNeeded);
p.Add(nameof(OnSuccess), parameter.OnSuccess);
});
}