Add Feedback Functions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@inherits FsBase
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
@inherits FsBase
|
||||
|
||||
@if (ShowNotNeeded)
|
||||
{
|
||||
@@ -25,14 +26,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (ShowInfo)
|
||||
@if (!string.IsNullOrWhiteSpace(Info1Name))
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@InfoName</FieldLabel>
|
||||
<FieldLabel>@Info1Name</FieldLabel>
|
||||
<TextEdit @bind-Text="Interaction.Info1"></TextEdit>
|
||||
</Field>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(Info2Name))
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@Info2Name</FieldLabel>
|
||||
<TextEdit @bind-Text="Interaction.Info2"></TextEdit>
|
||||
</Field>
|
||||
}
|
||||
|
||||
@if (AllowFeedback)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<Field>
|
||||
<FieldLabel>Feedback</FieldLabel>
|
||||
<br/>
|
||||
<Buttons>
|
||||
<Button Color="Color.Danger" Outline="@(Interaction.Feedback != InteractionFeedback.Negative)" Clicked="@(() => SetFeedbackAsync(InteractionFeedback.Negative))">
|
||||
<i class="fa-solid fa-thumbs-down"></i>
|
||||
</Button>
|
||||
<Button Color="Color.Warning" Outline="@(Interaction.Feedback != InteractionFeedback.Neutral)" Clicked="@(() => SetFeedbackAsync(InteractionFeedback.Neutral))">
|
||||
<i class="fa-solid fa-circle-dot"></i>
|
||||
</Button>
|
||||
<Button Color="Color.Success" Outline="@(Interaction.Feedback != InteractionFeedback.Positive)" Clicked="@(() => SetFeedbackAsync(InteractionFeedback.Positive))">
|
||||
<i class="fa-solid fa-thumbs-up"></i>
|
||||
</Button>
|
||||
</Buttons>
|
||||
</Field>
|
||||
</div>
|
||||
@if (Interaction.Feedback == InteractionFeedback.Negative)
|
||||
{
|
||||
<div class="col-sm">
|
||||
<Field>
|
||||
<FieldLabel>Feedback Info</FieldLabel>
|
||||
<TextEdit @bind-Text="Interaction.FeedbackInfo"></TextEdit>
|
||||
</Field>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<Button Color="Color.Secondary" Clicked="@ModalService.Hide">Abbrechen</Button>
|
||||
<Button Color="Color.Primary" Clicked="@AddInteractionAsync" Class="ml-2">OK</Button>
|
||||
|
||||
@@ -24,7 +24,13 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
#region Parameters
|
||||
|
||||
[Parameter]
|
||||
public string? InfoName { get; set; }
|
||||
public bool AllowFeedback { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? Info1Name { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? Info2Name { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Interaction Interaction { get; set; } = new();
|
||||
@@ -35,9 +41,6 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
[Parameter]
|
||||
public bool ShowAlert { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowInfo { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowNotNeeded { get; set; }
|
||||
|
||||
@@ -55,21 +58,26 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
/// </returns>
|
||||
public static async Task ShowAsync(IModalService modalService, InteractionDialogParameter parameter)
|
||||
{
|
||||
var showInfo = parameter.Type switch
|
||||
var allowFeedback = parameter.Type switch
|
||||
{
|
||||
InteractionType.EinAb => true,
|
||||
InteractionType.Complete => true,
|
||||
InteractionType.IdCheck => true,
|
||||
InteractionType.PrintPass => true,
|
||||
InteractionType.ReleasedForVerification => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
var infoName = parameter.Type switch
|
||||
var info1Name = parameter.Type switch
|
||||
{
|
||||
InteractionType.EinAb => "Welcher Betrieb?",
|
||||
InteractionType.Complete => "Kommentar",
|
||||
InteractionType.IdCheck => "Kommentar",
|
||||
InteractionType.PrintPass => "Kommentar",
|
||||
InteractionType.ReleasedForVerification => "Hinweis",
|
||||
_ => "Kommentar"
|
||||
_ => null
|
||||
};
|
||||
|
||||
var info2Name = parameter.Type switch
|
||||
{
|
||||
InteractionType.EinAb => "Mit wem?",
|
||||
_ => null
|
||||
};
|
||||
|
||||
var showAlert = parameter.Type switch
|
||||
@@ -95,8 +103,9 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
await modalService.Show<InteractionDialog>(parameter.HeaderText, p =>
|
||||
{
|
||||
p.Add(nameof(Interaction), interaction);
|
||||
p.Add(nameof(ShowInfo), showInfo);
|
||||
p.Add(nameof(InfoName), infoName);
|
||||
p.Add(nameof(AllowFeedback), allowFeedback);
|
||||
p.Add(nameof(Info1Name), info1Name);
|
||||
p.Add(nameof(Info2Name), info2Name);
|
||||
p.Add(nameof(ShowAlert), showAlert);
|
||||
p.Add(nameof(ShowNotNeeded), showNotNeeded);
|
||||
p.Add(nameof(OnSuccess), parameter.OnSuccess);
|
||||
@@ -124,5 +133,22 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method SetFeedbackAsync
|
||||
|
||||
/// <summary>
|
||||
/// Sets the feedback type for the interaction and updates the feedback property.
|
||||
/// </summary>
|
||||
/// <param name="feedback">The feedback type to be set for the interaction.</param>
|
||||
/// <returns>
|
||||
/// A task representing the asynchronous operation.
|
||||
/// </returns>
|
||||
private async Task SetFeedbackAsync(InteractionFeedback feedback)
|
||||
{
|
||||
Interaction.Feedback = feedback;
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user