Accounts, BookingRules, BookingTexts, BankTransactions each get an <FluentSearch> above the grid, backed by a computed Filtered IQueryable over an in-memory source list. FluentSearch is Immediate, so filtering happens on each keystroke; data sizes are small enough for per-render LINQ. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
91 lines
3.3 KiB
C#
91 lines
3.3 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 IReadOnlyList<BookingRuleDataset> source = [];
|
|
private string filter = "";
|
|
|
|
private IQueryable<BookingRuleDataset> Filtered =>
|
|
string.IsNullOrWhiteSpace(filter)
|
|
? source.AsQueryable()
|
|
: source.AsQueryable().Where(r =>
|
|
r.LookupText.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
|
(r.BookingText != null && r.BookingText.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
|
(r.Account != null && r.Account.Contains(filter, StringComparison.OrdinalIgnoreCase)));
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
source = await viewService.GetBookingRuleViewListAsync();
|
|
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)
|
|
{
|
|
source = await viewService.GetBookingRuleViewListAsync();
|
|
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)
|
|
{
|
|
source = await viewService.GetBookingRuleViewListAsync();
|
|
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);
|
|
source = await viewService.GetBookingRuleViewListAsync();
|
|
toastService.ShowToast(ToastIntent.Success, "Buchungsregel gelöscht", 3000);
|
|
}
|
|
}
|
|
}
|