Display prospect memo

This commit is contained in:
Andre Beging
2022-05-31 17:00:32 +02:00
parent 3487cdcb58
commit e21c9a7b52
4 changed files with 132 additions and 54 deletions

View File

@@ -20,7 +20,15 @@
<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> </small>
</h5> </h5>
<div>@Prospect?.Memo</div>
@if (!string.IsNullOrWhiteSpace(Prospect?.Memo))
{
<Alert Color="Color.Info" Visible Class="p-2 mb-1">
<AlertDescription>@Prospect?.Memo</AlertDescription>
</Alert>
}
<table> <table>
<InteractionRow <InteractionRow

View File

@@ -1,64 +1,31 @@
@using FoodsharingSiegen.Contracts.Entity @using FoodsharingSiegen.Contracts.Entity
@code {
private Modal ModalReference { get; set; } = null!;
private Prospect Prospect { get; set; } = new();
private string? Header { get; set; }
private string? SaveButtonText { get; set; }
private bool IsUpdateMode { get; set; }
[Parameter] public EventCallback<Prospect> OnAdd { get; set; }
[Parameter] public EventCallback<Prospect> OnUpdate { get; set; }
public async Task Show()
{
Prospect = new Prospect();
Header = "Neuling hinzufügen";
SaveButtonText = "Hinzufügen";
await ModalReference.Show();
}
public async Task Show(Prospect? prospect)
{
if (prospect == null) return;
Prospect = prospect;
IsUpdateMode = true;
Header = $"{Prospect.Name} bearbeiten";
SaveButtonText = "Speichern";
await ModalReference.Show();
}
private async Task SaveClick()
{
if (IsUpdateMode)
await OnUpdate.InvokeAsync(Prospect);
else
await OnAdd.InvokeAsync(Prospect);
await ModalReference.Hide();
}
}
<Modal @ref="@ModalReference"> <Modal @ref="@ModalReference">
<ModalContent Centered Size="ModalSize.Small"> <ModalContent Centered Size="ModalSize.Default">
<ModalHeader> <ModalHeader>
<ModalTitle>@Header</ModalTitle> <ModalTitle>@Header</ModalTitle>
<CloseButton /> <CloseButton/>
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<div class="row">
<div class="col">
<Field> <Field>
<FieldLabel>Name</FieldLabel> <FieldLabel>Name</FieldLabel>
<TextEdit @bind-Text="Prospect.Name" /> <TextEdit @bind-Text="Prospect.Name"/>
</Field> </Field>
</div>
<div class="col">
<Field> <Field>
<FieldLabel>Foodsharing-ID</FieldLabel> <FieldLabel>Foodsharing-ID</FieldLabel>
<NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit> <NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit>
</Field> </Field>
</div>
</div>
<Field>
<FieldLabel>Memo (optional)</FieldLabel>
<TextEdit @bind-Text="Prospect.Memo" Placeholder="Beliebige Info"></TextEdit>
</Field>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button Color="Color.Primary" Clicked="@SaveClick">@SaveButtonText</Button> <Button Color="Color.Primary" Clicked="@SaveClick">@SaveButtonText</Button>

View File

@@ -0,0 +1,103 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Dialogs
{
/// <summary>
/// The add prospect modal class (a. beging, 31.05.2022)
/// </summary>
public partial class AddProspectModal
{
#region Parameters
/// <summary>
/// Gets or sets the value of the on add (ab)
/// </summary>
[Parameter]
public EventCallback<Prospect> OnAdd { get; set; }
/// <summary>
/// Gets or sets the value of the on update (ab)
/// </summary>
[Parameter]
public EventCallback<Prospect> OnUpdate { get; set; }
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the header (ab)
/// </summary>
private string? Header { get; set; }
/// <summary>
/// Gets or sets the value of the is update mode (ab)
/// </summary>
private bool IsUpdateMode { get; set; }
/// <summary>
/// Gets or sets the value of the modal reference (ab)
/// </summary>
private Modal ModalReference { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the prospect (ab)
/// </summary>
private Prospect Prospect { get; set; } = new();
/// <summary>
/// Gets or sets the value of the save button text (ab)
/// </summary>
private string? SaveButtonText { get; set; }
#endregion
#region Public Method Show
/// <summary>
/// Shows this instance (a. beging, 31.05.2022)
/// </summary>
public async Task Show()
{
Prospect = new Prospect();
Header = "Neuling hinzufügen";
SaveButtonText = "Hinzufügen";
await ModalReference.Show();
}
/// <summary>
/// Shows the prospect (a. beging, 31.05.2022)
/// </summary>
/// <param name="prospect">The prospect</param>
public async Task Show(Prospect? prospect)
{
if (prospect == null) return;
Prospect = prospect;
IsUpdateMode = true;
Header = $"{Prospect.Name} bearbeiten";
SaveButtonText = "Speichern";
await ModalReference.Show();
}
#endregion
#region Private Method SaveClick
/// <summary>
/// Saves the click (a. beging, 31.05.2022)
/// </summary>
private async Task SaveClick()
{
if (IsUpdateMode)
await OnUpdate.InvokeAsync(Prospect);
else
await OnAdd.InvokeAsync(Prospect);
await ModalReference.Hide();
}
#endregion
}
}

View File

@@ -21,7 +21,7 @@
<span class="fas fa-tasks mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Übersicht <span class="fas fa-tasks mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Übersicht
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3"> <div class="nav-item px-3 mt-3">
<NavLink class="nav-link" href="users" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="users" Match="NavLinkMatch.All">
<span class="fas fa-users mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Benutzer <span class="fas fa-users mr-1" aria-hidden="true" style="font-size: 1.4em;"></span> Benutzer
</NavLink> </NavLink>