Confirm Dialog

This commit is contained in:
Andre Beging
2022-04-04 16:00:17 +02:00
parent 1513ed9169
commit b8dfeee518
4 changed files with 33 additions and 15 deletions

View File

@@ -11,3 +11,5 @@
</LayoutView> </LayoutView>
</NotFound> </NotFound>
</Router> </Router>
<MessageAlert />

View File

@@ -9,17 +9,21 @@
<ModalBody> <ModalBody>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<label for="aim-userselect">Benutzer</label> <Field>
<FieldLabel>Wer?</FieldLabel>
<Select TValue="Guid" @bind-SelectedValue="SelectedUser" id="aim-userselect"> <Select TValue="Guid" @bind-SelectedValue="SelectedUser" id="aim-userselect">
@foreach (var user in Users ?? new List<User>()) @foreach (var user in Users ?? new List<User>())
{ {
<SelectItem Value="@user.Id">@user.Name</SelectItem> <SelectItem Value="@user.Id">@user.Name</SelectItem>
} }
</Select> </Select>
</Field>
</div> </div>
<div class="col"> <div class="col">
<label for="aim-datepicker">Datum</label> <Field>
<FieldLabel>Wann?</FieldLabel>
<DatePicker TValue="DateTime" @bind-Date="Interaction.Date" ElementId="aim-datepicker" Max="DateTime.UtcNow.AddDays(7)"/> <DatePicker TValue="DateTime" @bind-Date="Interaction.Date" ElementId="aim-datepicker" Max="DateTime.UtcNow.AddDays(7)"/>
</Field>
</div> </div>
</div> </div>
@@ -31,8 +35,8 @@
} }
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button Color="Color.Primary" Clicked="@AddInteraction">Speichern</Button>
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button> <Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
<Button Color="Color.Primary" Clicked="@AddInteraction">Speichern</Button>
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>
</Modal> </Modal>

View File

@@ -37,8 +37,8 @@
</Field> </Field>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button Color="Color.Primary" Clicked="@AddProspect">Hinzufügen</Button>
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button> <Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
<Button Color="Color.Primary" Clicked="@AddProspect">Hinzufügen</Button>
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>
</Modal> </Modal>

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity; using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs; using FoodsharingSiegen.Server.Dialogs;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@@ -7,6 +8,7 @@ namespace FoodsharingSiegen.Server.Pages
{ {
public partial class Prospects public partial class Prospects
{ {
[Inject] IMessageService MessageService { get; set; }
[Inject] public ProspectService ProspectService { get; set; } = null!; [Inject] public ProspectService ProspectService { get; set; } = null!;
[Inject] public UserService UserService { get; set; } = null!; [Inject] public UserService UserService { get; set; } = null!;
@@ -56,9 +58,19 @@ namespace FoodsharingSiegen.Server.Pages
} }
private async Task RemoveInteraction(Guid arg) private async Task RemoveInteraction(Guid arg)
{
var confirm = await MessageService.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => {
o.ConfirmButtonText = "Ja, wirklich!";
o.CancelButtonText = "Abbrechen";
o.ShowMessageIcon = false;
});
if (confirm)
{ {
await ProspectService.RemoveInteraction(arg); await ProspectService.RemoveInteraction(arg);
await LoadProspects(); await LoadProspects();
} }
}
} }
} }