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>
82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.FluentUI.AspNetCore.Components;
|
|
using Schaad.Accounting.Datasets;
|
|
using Schaad.Accounting.Interfaces;
|
|
using Schaad.Accounting.Models;
|
|
using Schaad.Accounting.UI.Components.Pages.Dialogs;
|
|
|
|
namespace Schaad.Accounting.UI.Components.Pages;
|
|
|
|
public partial class BookingRules : ComponentBase
|
|
{
|
|
[Inject]
|
|
private IViewService viewService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IBookingRuleRepository bookingRuleRepository { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IDialogService dialogService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IToastService toastService { get; set; } = null!;
|
|
|
|
private IQueryable<BookingRuleDataset>? bookingRulesQueryable;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
bookingRulesQueryable = (await viewService.GetBookingRuleViewListAsync()).AsQueryable();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task AddAsync()
|
|
{
|
|
var data = new BookingRule();
|
|
var dialog = await dialogService.ShowDialogAsync<BookingRuleDialog>(data, new DialogParameters()
|
|
{
|
|
Height = "500px",
|
|
Title = "Buchungsregel",
|
|
PreventDismissOnOverlayClick = true,
|
|
PreventScroll = true,
|
|
});
|
|
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled && result.Data != null)
|
|
{
|
|
bookingRulesQueryable = (await viewService.GetBookingRuleViewListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungsregel gespeichert", 3000);
|
|
}
|
|
}
|
|
|
|
private async Task EditAsync(string id)
|
|
{
|
|
var data = await bookingRuleRepository.GetBookingRuleAsync(id);
|
|
var dialog = await dialogService.ShowDialogAsync<BookingRuleDialog>(data, new DialogParameters()
|
|
{
|
|
Height = "500px",
|
|
Title = "Buchungsregel",
|
|
PreventDismissOnOverlayClick = true,
|
|
PreventScroll = true,
|
|
});
|
|
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled && result.Data != null)
|
|
{
|
|
bookingRulesQueryable = (await viewService.GetBookingRuleViewListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungsregel gespeichert", 3000);
|
|
}
|
|
}
|
|
|
|
private async Task DeleteAsync(string id)
|
|
{
|
|
var bookingRule = await bookingRuleRepository.GetBookingRuleAsync(id);
|
|
var dialog = await dialogService.ShowConfirmationAsync($"Regel '{bookingRule.LookupText}' wirklich löschen?", "Ja", "Nein", "Buchungsregel löschen");
|
|
var result = await dialog.Result;
|
|
if (!result.Cancelled)
|
|
{
|
|
await bookingRuleRepository.DeleteBookingRuleAsync(id);
|
|
bookingRulesQueryable = (await viewService.GetBookingRuleViewListAsync()).AsQueryable();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungsregel gelöscht", 3000);
|
|
}
|
|
}
|
|
}
|