Fixed a bunch of warnings

This commit is contained in:
Andre Beging
2022-05-31 15:08:55 +02:00
parent cd22c2f215
commit 7208f1e86d
21 changed files with 202 additions and 140 deletions

View File

@@ -1,46 +1,5 @@
@using FoodsharingSiegen.Contracts.Entity
@code {
[Parameter]
public Prospect Prospect { get; set; }
[Parameter]
public InteractionType Type { get; set; }
[Parameter]
public EventCallback AddClick { get; set; }
[Parameter]
public EventCallback<Guid> RemoveClick { get; set; }
[Parameter]
public string Caption { get; set; }
[Parameter]
public string ButtonText { get; set; }
[Parameter]
public string IconClass { get; set; }
[Parameter]
public bool Multiple { get; set; }
[Parameter]
public int Minimum { get; set; } = 1;
[Parameter]
public bool AllowAddInteraction { get; set; }
private List<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
private bool Done => Interactions.Count >= Minimum;
private bool NotNeeded => Interactions.Any(x => x.NotNeeded);
private bool Alert => Interactions.Any(x => x.Alert);
}
@{
var rowClass = "";
if (Done) rowClass += " done";
@@ -65,7 +24,7 @@
<span>(<i>@interaction.Info</i>)</span>
}
@if ((!Prospect.Complete || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
@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>
}
@@ -74,7 +33,7 @@
}
}
@if (!Prospect.Complete && (Interactions.Count == 0 || Multiple) && AllowAddInteraction)
@if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction)
{
if (Multiple) ButtonText = "+";
<Button Size="Size.Small" Clicked="AddClick">@ButtonText</Button>

View File

@@ -0,0 +1,99 @@
using FoodsharingSiegen.Contracts.Entity;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Controls
{
/// <summary>
/// The interaction row class (a. beging, 31.05.2022)
/// </summary>
public partial class InteractionRow
{
#region Parameters
/// <summary>
/// Gets or sets the value of the add click (ab)
/// </summary>
[Parameter]
public EventCallback AddClick { get; set; }
/// <summary>
/// Gets or sets the value of the allow add interaction (ab)
/// </summary>
[Parameter]
public bool AllowAddInteraction { get; set; }
/// <summary>
/// Gets or sets the value of the button text (ab)
/// </summary>
[Parameter]
public string? ButtonText { get; set; }
/// <summary>
/// Gets or sets the value of the caption (ab)
/// </summary>
[Parameter]
public string? Caption { get; set; }
/// <summary>
/// Gets or sets the value of the icon class (ab)
/// </summary>
[Parameter]
public string? IconClass { get; set; }
/// <summary>
/// Gets or sets the value of the minimum (ab)
/// </summary>
[Parameter]
public int Minimum { get; set; } = 1;
/// <summary>
/// Gets or sets the value of the multiple (ab)
/// </summary>
[Parameter]
public bool Multiple { get; set; }
/// <summary>
/// Gets or sets the value of the prospect (ab)
/// </summary>
[Parameter]
public Prospect? Prospect { get; set; }
/// <summary>
/// Gets or sets the value of the remove click (ab)
/// </summary>
[Parameter]
public EventCallback<Guid> RemoveClick { get; set; }
/// <summary>
/// Gets or sets the value of the type (ab)
/// </summary>
[Parameter]
public InteractionType Type { get; set; }
#endregion
#region Private Properties
/// <summary>
/// Gets the value of the alert (ab)
/// </summary>
private bool Alert => Interactions.Any(x => x.Alert);
/// <summary>
/// Gets the value of the done (ab)
/// </summary>
private bool Done => Interactions.Count >= Minimum;
/// <summary>
/// Gets the value of the interactions (ab)
/// </summary>
private List<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
/// <summary>
/// Gets the value of the not needed (ab)
/// </summary>
private bool NotNeeded => Interactions.Any(x => x.NotNeeded);
#endregion
}
}

View File

@@ -5,7 +5,7 @@
@{
var divClass = $"{CssClass} pc-main";
if (Prospect.Complete) divClass += " complete";
if (Prospect is {Complete: true }) divClass += " complete";
}
<div class="@divClass">
@@ -15,12 +15,12 @@
<a href=""><i class="fa-solid fa-pen-to-square" @onclick="() => ProspectModal.Show(Prospect)" @onclick:preventDefault></i> </a>
}
@Prospect.Name
@Prospect?.Name
<small style="font-size: .9rem; opacity: .7;">
<a class="invert" href="@(CurrentUser.NetworkLink)/profile/@Prospect.FsId" target="_blank">Profil öffnen</a>
<a class="invert" href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank">Profil öffnen</a>
</small>
</h5>
<div>@Prospect.Memo</div>
<div>@Prospect?.Memo</div>
<table>
<InteractionRow