Display prospect memo
This commit is contained in:
@@ -1,63 +1,30 @@
|
||||
@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">
|
||||
<ModalContent Centered Size="ModalSize.Small">
|
||||
<ModalContent Centered Size="ModalSize.Default">
|
||||
<ModalHeader>
|
||||
<ModalTitle>@Header</ModalTitle>
|
||||
<CloseButton />
|
||||
<CloseButton/>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<Field>
|
||||
<FieldLabel>Name</FieldLabel>
|
||||
<TextEdit @bind-Text="Prospect.Name"/>
|
||||
</Field>
|
||||
</div>
|
||||
<div class="col">
|
||||
<Field>
|
||||
<FieldLabel>Foodsharing-ID</FieldLabel>
|
||||
<NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit>
|
||||
</Field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Field>
|
||||
<FieldLabel>Name</FieldLabel>
|
||||
<TextEdit @bind-Text="Prospect.Name" />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Foodsharing-ID</FieldLabel>
|
||||
<NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit>
|
||||
<FieldLabel>Memo (optional)</FieldLabel>
|
||||
<TextEdit @bind-Text="Prospect.Memo" Placeholder="Beliebige Info"></TextEdit>
|
||||
</Field>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
|
||||
Reference in New Issue
Block a user