Add IToastService.ShowToast(ToastIntent.Success, ...) after each successful save/delete across Accounts, BookingRules, BookingTexts, Classes, and Transactions. Toasts fire after the list re-fetch so the confirmation is visible even if the edited item paginated out of view. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.FluentUI.AspNetCore.Components;
|
|
using Schaad.Accounting.Interfaces;
|
|
using Schaad.Accounting.Models;
|
|
using Schaad.Accounting.UI.Components.Pages.Dialogs;
|
|
|
|
namespace Schaad.Accounting.UI.Components.Pages;
|
|
|
|
public partial class BookingTexts : ComponentBase
|
|
{
|
|
[Inject]
|
|
private IBookingTextRepository bookingTextRepository { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IDialogService dialogService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IToastService toastService { get; set; } = null!;
|
|
|
|
private IQueryable<BookingText>? bookingTextQueryable;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
bookingTextQueryable = (await bookingTextRepository.GetBookingTextListAsync()).AsQueryable();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task AddAsync()
|
|
{
|
|
var data = new BookingText();
|
|
var dialog = await dialogService.ShowDialogAsync<BookingTextDialog>(data, new DialogParameters()
|
|
{
|
|
Height = "500px",
|
|
Title = "Add Buchungstext",
|
|
PreventDismissOnOverlayClick = true,
|
|
PreventScroll = true,
|
|
});
|
|
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled && result.Data != null)
|
|
{
|
|
bookingTextQueryable = (await bookingTextRepository.GetBookingTextListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungstext gespeichert", 3000);
|
|
}
|
|
}
|
|
|
|
private async Task EditAsync(string id)
|
|
{
|
|
var data = await bookingTextRepository.GetBookingTextAsync(id);
|
|
var dialog = await dialogService.ShowDialogAsync<BookingTextDialog>(data, new DialogParameters()
|
|
{
|
|
Height = "500px",
|
|
Title = "Edit Buchungstext",
|
|
PreventDismissOnOverlayClick = true,
|
|
PreventScroll = true,
|
|
});
|
|
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled && result.Data != null)
|
|
{
|
|
bookingTextQueryable = (await bookingTextRepository.GetBookingTextListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungstext gespeichert", 3000);
|
|
}
|
|
}
|
|
|
|
private async Task DeleteAsync(string id)
|
|
{
|
|
var bookingText = await bookingTextRepository.GetBookingTextAsync(id);
|
|
var dialog = await dialogService.ShowConfirmationAsync($"Buchungstext '{bookingText.Text}' wirklich löschen?", "Ja", "Nein", "Buchungstext löschen");
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled)
|
|
{
|
|
await bookingTextRepository.DeleteBookingTextAsync(id);
|
|
bookingTextQueryable = (await bookingTextRepository.GetBookingTextListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungstext gelöscht", 3000);
|
|
}
|
|
}
|
|
}
|