Add edit functionality for EinAb interactions: implement UpdateInteraction method, extend InteractionDialog for edit mode, and add edit button in InteractionRow

This commit is contained in:
troogs
2026-09-14 16:09:13 +02:00
parent fdd7ea5a40
commit 8b298b37c7
11 changed files with 360 additions and 24 deletions
@@ -45,11 +45,29 @@ else
@foreach (var interaction in Interactions)
{
<div class="d-flex justify-content-end">
<div class="d-flex justify-content-end align-items-center interaction-row-action-group">
@if ((Prospect is not { Complete: true } || interaction.Type == InteractionType.Complete) && AllowInteraction)
{
<a style="display: inline-block;"" href=""><i class="fa-solid fa-square-xmark" @onclick="async () => { if (RemoveClick != null) await RemoveClick.Invoke(interaction.Id); }" @onclick:preventDefault></i></a>
} else {
<div class="d-flex align-items-center interaction-row-actions">
@if (AllowEdit)
{
<Button Size="Size.Small"
Class="interaction-row-action interaction-row-action-edit"
title="Eintrag bearbeiten"
Clicked="@(async () => { if (EditClick != null) await EditClick.Invoke(interaction.Id); })">
<i class="fa-solid fa-pen-to-square"></i>
</Button>
}
<Button Size="Size.Small"
Class="interaction-row-action interaction-row-action-delete"
title="Eintrag löschen"
Clicked="@(async () => { if (RemoveClick != null) await RemoveClick.Invoke(interaction.Id); })">
<i class="fa-solid fa-square-xmark"></i>
</Button>
</div>
}
else
{
<span>&bull;</span>
}
</div>
@@ -62,6 +62,18 @@ namespace FoodsharingSiegen.Server.Controls
[Parameter]
public Func<Guid, Task>? RemoveClick { get; set; }
/// <summary>
/// Gets or sets whether editing existing interactions is allowed.
/// </summary>
[Parameter]
public bool AllowEdit { get; set; }
/// <summary>
/// Gets or sets the callback invoked when an interaction is edited.
/// </summary>
[Parameter]
public Func<Guid, Task>? EditClick { get; set; }
/// <summary>
/// Gets or sets the value of the type (ab)
/// </summary>
@@ -1,4 +1,38 @@
tr.done th {
.interaction-row-action-group {
gap: 0.25rem;
min-width: 2.7rem;
}
.interaction-row-actions {
gap: 0.25rem;
}
.interaction-row-action {
width: 1rem;
min-width: 1.25rem;
height: 1.25rem;
min-height: 1.25rem;
padding: 0;
display: inline-flex !important;
align-items: center;
justify-content: center;
font-size: 0.7rem;
line-height: 1;
}
.interaction-row-action i {
font-size: 0.95rem;
}
.interaction-row-action-edit i {
color: #1f2f3a;
}
.interaction-row-action-delete i {
color: rgb(153, 0, 0);
}
tr.done th {
color: #64ae24;
}
@@ -81,6 +81,8 @@
AllowInteraction="@(StateFilter == ProspectStateFilter.OnBoarding && CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))"
AddClick="AddInteraction"
RemoveClick="@RemoveInteraction"
AllowEdit="true"
EditClick="@EditInteraction"
Multiple="true"
Minimum="3"
ButtonIconClass="fa-solid fa-plus"
@@ -62,6 +62,24 @@ namespace FoodsharingSiegen.Server.Controls
#endregion
#region Private Method EditInteraction
private async Task EditInteraction(Guid interactionId)
{
if (Prospect == null || OnDataChanged == null) return;
var interaction = Prospect.Interactions.FirstOrDefault(x => x.Id == interactionId);
if (interaction == null || !InteractionDialog.IsEditable(interaction.Type)) return;
var headerText = $"{interaction.Type.Translate(AppSettings)} für {Prospect.Name} bearbeiten";
Func<Task> onSuccess = async () => await OnDataChanged();
await InteractionDialog.ShowAsync(ModalService, new(interaction.Type, Prospect.Id, headerText, onSuccess, interaction));
}
#endregion
#region Private Method DeleteProspectAsync
/// <summary>