InteractionModal umstellen
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using FoodsharingSiegen.Server.Dialogs;
|
using FoodsharingSiegen.Server.Dialogs;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
@@ -8,18 +9,17 @@ namespace FoodsharingSiegen.Server.Controls
|
|||||||
{
|
{
|
||||||
[Parameter] public Prospect? Prospect { get; set; }
|
[Parameter] public Prospect? Prospect { get; set; }
|
||||||
|
|
||||||
[Parameter] public AddInteractionModal InteractionModal { get; set; } = null!;
|
|
||||||
|
|
||||||
[Parameter] public Func<Guid, Task>? RemoveInteraction { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public ProspectStateFilter StateFilter { get; set; }
|
[Parameter] public ProspectStateFilter StateFilter { get; set; }
|
||||||
|
|
||||||
[Parameter] public string? CssClass { get; set; }
|
[Parameter] public string? CssClass { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public Func<Task>? OnDataChanged { get; set; }
|
||||||
|
|
||||||
|
|
||||||
private async Task AddInteraction(InteractionType type)
|
private async Task AddInteraction(InteractionType type)
|
||||||
{
|
{
|
||||||
await InteractionModal.ShowAsync(type, Prospect?.Id);
|
if (Prospect != null && OnDataChanged != null)
|
||||||
|
await AddInteractionModal.ShowAsync(ModalService, OnDataChanged, type, Prospect.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Interaction> GetTyped(InteractionType type)
|
private List<Interaction> GetTyped(InteractionType type)
|
||||||
@@ -31,5 +31,27 @@ namespace FoodsharingSiegen.Server.Controls
|
|||||||
{
|
{
|
||||||
await EditProspectDialog.ShowAsync(ModalService, () => InvokeAsync(StateHasChanged), Prospect);
|
await EditProspectDialog.ShowAsync(ModalService, () => InvokeAsync(StateHasChanged), Prospect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the prospect service (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
public ProspectService ProspectService { get; set; } = null!;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
var removeR = await ProspectService.RemoveInteraction(arg);
|
||||||
|
if(removeR.Success && OnDataChanged != null) await OnDataChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,10 @@
|
|||||||
|
|
||||||
[Parameter] public List<Prospect>? Prospects { get; set; }
|
[Parameter] public List<Prospect>? Prospects { get; set; }
|
||||||
|
|
||||||
[Parameter] public Func<Guid, Task>? OnRemoveInteraction { get; set; }
|
|
||||||
|
|
||||||
[Parameter] public AddInteractionModal InteractionModal { get; set; } = null!;
|
|
||||||
|
|
||||||
[Parameter] public ProspectStateFilter StateFilter { get; set; }
|
[Parameter] public ProspectStateFilter StateFilter { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public Func<Task>? OnDataChanged { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
<h5>@(Prospects?.Count ?? 0) Einträge</h5>
|
<h5>@(Prospects?.Count ?? 0) Einträge</h5>
|
||||||
|
|
||||||
@@ -19,8 +17,7 @@
|
|||||||
<Repeater Items="@Prospects">
|
<Repeater Items="@Prospects">
|
||||||
<ProspectContainer
|
<ProspectContainer
|
||||||
Prospect="context"
|
Prospect="context"
|
||||||
InteractionModal="@InteractionModal"
|
OnDataChanged="@OnDataChanged"
|
||||||
RemoveInteraction="OnRemoveInteraction"
|
|
||||||
StateFilter="StateFilter"></ProspectContainer>
|
StateFilter="StateFilter"></ProspectContainer>
|
||||||
</Repeater>
|
</Repeater>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
@using FoodsharingSiegen.Contracts.Entity
|
@inherits FsBase
|
||||||
|
|
||||||
@inherits FsBase
|
@if (ShowNotNeeded)
|
||||||
|
|
||||||
<Modal @ref="ModalReference">
|
|
||||||
<ModalContent Centered Size="ModalSize.Default">
|
|
||||||
<ModalHeader>
|
|
||||||
<h6>@_header</h6>
|
|
||||||
<CloseButton/>
|
|
||||||
</ModalHeader>
|
|
||||||
<ModalBody>
|
|
||||||
@if (_showNotNeeded)
|
|
||||||
{
|
{
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@@ -26,17 +17,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@* <div class="col"> *@
|
|
||||||
@* <Field> *@
|
|
||||||
@* <FieldLabel>Wer?</FieldLabel> *@
|
|
||||||
@* <Select TValue="Guid" @bind-SelectedValue="SelectedUser"> *@
|
|
||||||
@* @foreach (var user in Users ?? []) *@
|
|
||||||
@* { *@
|
|
||||||
@* <SelectItem Value="@user.Id">@user.Name</SelectItem> *@
|
|
||||||
@* } *@
|
|
||||||
@* </Select> *@
|
|
||||||
@* </Field> *@
|
|
||||||
@* </div> *@
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel>Wann?</FieldLabel>
|
<FieldLabel>Wann?</FieldLabel>
|
||||||
@@ -45,17 +25,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (_showInfo)
|
@if (ShowInfo)
|
||||||
{
|
{
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel>@_infoName</FieldLabel>
|
<FieldLabel>@InfoName</FieldLabel>
|
||||||
<TextEdit @bind-Text="Interaction.Info"></TextEdit>
|
<TextEdit @bind-Text="Interaction.Info"></TextEdit>
|
||||||
</Field>
|
</Field>
|
||||||
}
|
}
|
||||||
</ModalBody>
|
|
||||||
<ModalFooter>
|
<Button Color="Color.Secondary" Clicked="@ModalService.Hide">Abbrechen</Button>
|
||||||
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
|
<Button Color="Color.Primary" Clicked="@AddInteractionAsync">OK</Button>
|
||||||
<Button Color="Color.Primary" Clicked="@AddInteraction">OK</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
@@ -1,104 +1,151 @@
|
|||||||
using Blazorise;
|
using Blazorise;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Server.BaseClasses;
|
||||||
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.Dialogs
|
namespace FoodsharingSiegen.Server.Dialogs
|
||||||
{
|
{
|
||||||
public partial class AddInteractionModal
|
public partial class AddInteractionModal : FsBase
|
||||||
{
|
{
|
||||||
private Modal ModalReference { get; set; } = null!;
|
#region Dependencies
|
||||||
|
|
||||||
private Interaction Interaction { get; set; } = new();
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the prospect service (ab)
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
public ProspectService ProspectService { get; set; } = null!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Parameters
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<Interaction> OnAdd { get; set; }
|
public string? InfoName { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public List<User>? Users { get; set; }
|
public Interaction Interaction { get; set; } = new();
|
||||||
|
|
||||||
public Guid SelectedUser { get; set; }
|
[Parameter]
|
||||||
|
public Func<Task>? OnSuccess { get; set; }
|
||||||
|
|
||||||
private string? _header;
|
[Parameter]
|
||||||
private string? _infoName;
|
public bool ShowAlert { get; set; }
|
||||||
private bool _showInfo;
|
|
||||||
private bool _showAlert;
|
|
||||||
private bool _showNotNeeded;
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
[Parameter]
|
||||||
|
public bool ShowInfo { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool ShowNotNeeded { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#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.
|
||||||
|
/// </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>
|
||||||
|
/// <returns>
|
||||||
|
/// A task representing the asynchronous operation of showing the modal dialog.
|
||||||
|
/// </returns>
|
||||||
|
public static async Task ShowAsync(IModalService modalService, Func<Task> onSuccess, InteractionType type, Guid prospectId)
|
||||||
{
|
{
|
||||||
if (Users?.Any() == true) SelectedUser = Users.First().Id;
|
var headerText = type switch
|
||||||
|
|
||||||
await base.OnParametersSetAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ShowAsync(InteractionType type, Guid? prospectId)
|
|
||||||
{
|
{
|
||||||
if (prospectId == null) return;
|
InteractionType.EinAb => "Einführung eintragen",
|
||||||
_showInfo = false;
|
InteractionType.Welcome => "Begrüßung eintragen",
|
||||||
_showNotNeeded = false;
|
InteractionType.IdCheck => "Ausweisprüfung eintragen",
|
||||||
_showAlert = false;
|
InteractionType.PrintPass => "FS-Ausweis (Print)",
|
||||||
_infoName = "Kommentar";
|
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"
|
||||||
|
};
|
||||||
|
|
||||||
switch (type)
|
var showInfo = type switch
|
||||||
{
|
{
|
||||||
case InteractionType.EinAb:
|
InteractionType.EinAb => true,
|
||||||
_header = "Einführung eintragen";
|
InteractionType.Complete => true,
|
||||||
_showInfo = true;
|
InteractionType.IdCheck => true,
|
||||||
_showAlert = true;
|
InteractionType.PrintPass => true,
|
||||||
_infoName = "Welcher Betrieb?";
|
InteractionType.PdfPass => true,
|
||||||
break;
|
InteractionType.ReleasedForVerification => true,
|
||||||
case InteractionType.Welcome:
|
_ => false
|
||||||
_header = "Begrüßung eintragen";
|
};
|
||||||
break;
|
|
||||||
case InteractionType.IdCheck:
|
|
||||||
_header = "Ausweisprüfung eintragen";
|
|
||||||
_showAlert = true;
|
|
||||||
_showInfo = true;
|
|
||||||
break;
|
|
||||||
case InteractionType.PrintPass:
|
|
||||||
_header = "FS-Ausweis (Print)";
|
|
||||||
_showNotNeeded = true;
|
|
||||||
_showInfo = true;
|
|
||||||
break;
|
|
||||||
case InteractionType.PdfPass:
|
|
||||||
_header = "FS-Ausweis (PDF)";
|
|
||||||
_showNotNeeded = true;
|
|
||||||
_showInfo = true;
|
|
||||||
break;
|
|
||||||
case InteractionType.Verify:
|
|
||||||
_header = "Verifizierung eintragen";
|
|
||||||
break;
|
|
||||||
case InteractionType.Complete:
|
|
||||||
_header = "Als fertig markieren";
|
|
||||||
_showInfo = true;
|
|
||||||
break;
|
|
||||||
case InteractionType.StepInBriefing:
|
|
||||||
_header = $"{AppSettings.Terms.StepInName} absolviert";
|
|
||||||
break;
|
|
||||||
case InteractionType.ReleasedForVerification:
|
|
||||||
_header = "Zur Verifizierung freigegeben";
|
|
||||||
_showInfo = true;
|
|
||||||
_infoName = "Hinweis";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Interaction = new Interaction
|
var infoName = type switch
|
||||||
|
{
|
||||||
|
InteractionType.EinAb => "Welcher Betrieb?",
|
||||||
|
InteractionType.ReleasedForVerification => "Hinweis",
|
||||||
|
_ => "Kommentar"
|
||||||
|
};
|
||||||
|
|
||||||
|
var showAlert = type switch
|
||||||
|
{
|
||||||
|
InteractionType.EinAb => true,
|
||||||
|
InteractionType.IdCheck => true,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
var showNotNeeded = type switch
|
||||||
|
{
|
||||||
|
InteractionType.PrintPass => true,
|
||||||
|
InteractionType.PdfPass => true,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
var interaction = new Interaction
|
||||||
{
|
{
|
||||||
Type = type,
|
Type = type,
|
||||||
Date = DateTime.UtcNow,
|
Date = DateTime.UtcNow,
|
||||||
ProspectID = prospectId.Value
|
ProspectID = prospectId
|
||||||
};
|
};
|
||||||
await ModalReference.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task AddInteraction()
|
await modalService.Show<AddInteractionModal>(headerText, parameter =>
|
||||||
{
|
{
|
||||||
Interaction.UserID = SelectedUser;
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await OnAdd.InvokeAsync(Interaction);
|
#endregion
|
||||||
await ModalReference.Hide();
|
|
||||||
}
|
#region Private Method AddInteractionAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new interaction for the current user using the ProspectService and hides the modal.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A task representing the asynchronous operation.
|
||||||
|
/// </returns>
|
||||||
|
private async Task AddInteractionAsync()
|
||||||
|
{
|
||||||
|
Interaction.UserID = CurrentUser.Id;
|
||||||
|
|
||||||
|
var addR = await ProspectService.AddInteraction(Interaction);
|
||||||
|
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||||
|
|
||||||
|
await ModalService.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,9 +24,6 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<ProspectGrid
|
<ProspectGrid
|
||||||
Prospects="filterList"
|
Prospects="filterList"
|
||||||
OnRemoveInteraction="RemoveInteractionAsync"
|
OnDataChanged="@LoadProspects"
|
||||||
StateFilter="ProspectStateFilter.OnBoarding"
|
StateFilter="ProspectStateFilter.OnBoarding">
|
||||||
InteractionModal="InteractionModal">
|
|
||||||
</ProspectGrid>
|
</ProspectGrid>
|
||||||
|
|
||||||
<AddInteractionModal @ref="InteractionModal" OnAdd="OnAddInteraction" Users="Users"></AddInteractionModal>
|
|
||||||
@@ -97,49 +97,6 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Method OnAddInteraction
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ons the add interaction using the specified arg (a. beging, 11.04.2022)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="arg">The arg</param>
|
|
||||||
private async Task OnAddInteraction(Interaction arg)
|
|
||||||
{
|
|
||||||
arg.UserID = CurrentUser.Id;
|
|
||||||
await ProspectService.AddInteraction(arg);
|
|
||||||
await LoadProspects();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Method OnAddProspect
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ons the add prospect using the specified arg (a. beging, 11.04.2022)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="arg">The arg</param>
|
|
||||||
private async Task OnAddProspect(Prospect arg)
|
|
||||||
{
|
|
||||||
var addProspectR = await ProspectService.AddProspectAsync(arg);
|
|
||||||
if (addProspectR.Success) await LoadProspects();
|
|
||||||
}
|
|
||||||
|
|
||||||
#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 RemoveInteractionAsync
|
#region Private Method RemoveInteractionAsync
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -14,14 +14,8 @@
|
|||||||
<hr/>
|
<hr/>
|
||||||
<ProspectFilterControl @bind-Filter="Filter"></ProspectFilterControl>
|
<ProspectFilterControl @bind-Filter="Filter"></ProspectFilterControl>
|
||||||
<hr />
|
<hr />
|
||||||
<h5>@(filterList.Count) Einträge</h5>
|
<ProspectGrid
|
||||||
@if (filterList.Any())
|
Prospects="filterList"
|
||||||
{
|
OnDataChanged="@LoadProspects"
|
||||||
<div class="row m-0">
|
StateFilter="ProspectStateFilter.Verification">
|
||||||
<Repeater Items="@filterList">
|
</ProspectGrid>
|
||||||
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" RemoveInteraction="RemoveInteraction" StateFilter="ProspectStateFilter.Verification"></ProspectContainer>
|
|
||||||
</Repeater>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<AddInteractionModal @ref="InteractionModal" OnAdd="OnAddInteraction" Users="Users"></AddInteractionModal>
|
|
||||||
@@ -31,11 +31,6 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
private ProspectFilter Filter { get; set; } = new();
|
private ProspectFilter Filter { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the interaction modal (ab)
|
|
||||||
/// </summary>
|
|
||||||
private AddInteractionModal? InteractionModal { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the prospect list (ab)
|
/// Gets or sets the value of the prospect list (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -84,21 +79,6 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Method OnAddInteraction
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ons the add interaction using the specified arg (a. beging, 11.04.2022)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="arg">The arg</param>
|
|
||||||
private async Task OnAddInteraction(Interaction arg)
|
|
||||||
{
|
|
||||||
arg.UserID = CurrentUser.Id;
|
|
||||||
await ProspectService.AddInteraction(arg);
|
|
||||||
await LoadProspects();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Method OnUpdateProspect
|
#region Private Method OnUpdateProspect
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user