AddInteractionModal, AddProspectModal
This commit is contained in:
30
FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor
Normal file
30
FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
@using FoodsharingSiegen.Contracts.Entity
|
||||||
|
|
||||||
|
<Modal @ref="ModalReference">
|
||||||
|
<ModalContent Centered Size="ModalSize.Small">
|
||||||
|
<ModalHeader>
|
||||||
|
<h6>@_header</h6>
|
||||||
|
<CloseButton/>
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Field>
|
||||||
|
<Select TValue="Guid" @bind-SelectedValue="SelectedUser">
|
||||||
|
@foreach (var user in Users ?? new List<User>())
|
||||||
|
{
|
||||||
|
<SelectItem Value="@user.Id">@user.Name</SelectItem>
|
||||||
|
}
|
||||||
|
</Select>
|
||||||
|
</Field>
|
||||||
|
@if (_showInfo)
|
||||||
|
{
|
||||||
|
<Field>
|
||||||
|
<MemoEdit @bind-Text="Interaction.Info" Placeholder="@_infoName" Rows="5"/>
|
||||||
|
</Field>
|
||||||
|
}
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button Color="Color.Primary" Clicked="@AddInteraction">Speichern</Button>
|
||||||
|
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
using Blazorise;
|
||||||
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace FoodsharingSiegen.Server.Dialogs
|
||||||
|
{
|
||||||
|
public partial class AddInteractionModal
|
||||||
|
{
|
||||||
|
private Modal ModalReference { get; set; } = null!;
|
||||||
|
|
||||||
|
private Interaction Interaction { get; set; } = new();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<Interaction> OnAdd { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public List<User>? Users { get; set; }
|
||||||
|
|
||||||
|
public Guid SelectedUser { get; set; }
|
||||||
|
|
||||||
|
private string _header;
|
||||||
|
private string _infoName;
|
||||||
|
private bool _showInfo;
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if (Users?.Any() == true)SelectedUser = Users.First().Id;
|
||||||
|
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Show(InteractionType type, Guid? prospectId)
|
||||||
|
{
|
||||||
|
if (prospectId == null) return;
|
||||||
|
_showInfo = false;
|
||||||
|
_infoName = "Kommentar";
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case InteractionType.EinAb:
|
||||||
|
_header = "Einführung eintragen";
|
||||||
|
_showInfo = true;
|
||||||
|
_infoName = "Betrieb";
|
||||||
|
break;
|
||||||
|
case InteractionType.Welcome:
|
||||||
|
_header = "Begrüßung eintragen";
|
||||||
|
break;
|
||||||
|
case InteractionType.IdCheck:
|
||||||
|
_header = "Ausweisprüfung eintragen";
|
||||||
|
_showInfo = true;
|
||||||
|
break;
|
||||||
|
case InteractionType.PrintPass:
|
||||||
|
_header = "FS-Ausweis (Print)";
|
||||||
|
_showInfo = true;
|
||||||
|
break;
|
||||||
|
case InteractionType.PdfPass:
|
||||||
|
_header = "FS-Ausweis (PDF)";
|
||||||
|
_showInfo = true;
|
||||||
|
break;
|
||||||
|
case InteractionType.Verify:
|
||||||
|
_header = "Verifizierung eintragen";
|
||||||
|
break;
|
||||||
|
case InteractionType.Complete:
|
||||||
|
_header = "Als fertig markieren";
|
||||||
|
_showInfo = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Interaction = new Interaction
|
||||||
|
{
|
||||||
|
Type = type,
|
||||||
|
Date = DateTime.UtcNow,
|
||||||
|
ProspectId = prospectId.Value
|
||||||
|
};
|
||||||
|
await ModalReference.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddInteraction()
|
||||||
|
{
|
||||||
|
Interaction.UserId = SelectedUser;
|
||||||
|
|
||||||
|
await OnAdd.InvokeAsync(Interaction);
|
||||||
|
await ModalReference.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor
Normal file
44
FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
@using FoodsharingSiegen.Contracts.Entity
|
||||||
|
@code {
|
||||||
|
private Modal ModalReference { get; set; } = null!;
|
||||||
|
|
||||||
|
private Prospect Prospect { get; set; } = new();
|
||||||
|
|
||||||
|
[Parameter] public EventCallback<Prospect> OnAdd { get; set; }
|
||||||
|
|
||||||
|
public async Task Show()
|
||||||
|
{
|
||||||
|
Prospect = new();
|
||||||
|
await ModalReference.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddProspect()
|
||||||
|
{
|
||||||
|
await OnAdd.InvokeAsync(Prospect);
|
||||||
|
await ModalReference.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<Modal @ref="@ModalReference">
|
||||||
|
<ModalContent Centered Size="ModalSize.Small">
|
||||||
|
<ModalHeader>
|
||||||
|
<ModalTitle>Neuling hinzufügen</ModalTitle>
|
||||||
|
<CloseButton />
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel>Name</FieldLabel>
|
||||||
|
<TextEdit @bind-Text="Prospect.Name" />
|
||||||
|
</Field>
|
||||||
|
<Field>
|
||||||
|
<FieldLabel>Foodsharing-ID</FieldLabel>
|
||||||
|
<NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit>
|
||||||
|
</Field>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button Color="Color.Primary" Clicked="@AddProspect">Hinzufügen</Button>
|
||||||
|
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
Reference in New Issue
Block a user