refactor(app): implement year filtering for accounts and enhance dashboard PDF generation
This commit is contained in:
@@ -11,6 +11,9 @@ public partial class Dashboard
|
||||
private bool showAddAccount;
|
||||
private bool showEditClubName;
|
||||
private bool showRestoreConfirm;
|
||||
private bool showYearFilterDialog;
|
||||
private int? selectedYear = DateTime.Now.Year;
|
||||
private List<int> availableYears = [];
|
||||
private string clubName = string.Empty;
|
||||
private string? operationMessage;
|
||||
private string operationMessageClass = "alert-info";
|
||||
@@ -31,16 +34,22 @@ public partial class Dashboard
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadClubName();
|
||||
await LoadAccounts();
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Loading
|
||||
|
||||
private async Task LoadAll()
|
||||
{
|
||||
await LoadAccounts();
|
||||
availableYears = await EntryService.GetAllEntryYearsAsync();
|
||||
}
|
||||
|
||||
private async Task LoadAccounts()
|
||||
{
|
||||
accounts = await AccountService.GetAllAccountsAsync();
|
||||
accounts = await AccountService.GetAllAccountsAsync(selectedYear);
|
||||
}
|
||||
|
||||
private async Task LoadClubName()
|
||||
@@ -56,7 +65,7 @@ public partial class Dashboard
|
||||
{
|
||||
await AccountService.CreateAccountAsync(name);
|
||||
showAddAccount = false;
|
||||
await LoadAccounts();
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleSaveClubName(string newName)
|
||||
@@ -104,8 +113,26 @@ public partial class Dashboard
|
||||
|
||||
private async Task HandleDashboardExportAsync()
|
||||
{
|
||||
var pdf = await PdfStatementService.GenerateDashboardStatementAsync();
|
||||
savedPdfPath = await FileSaveService.SaveFileAsync(pdf, $"{DisplayClubName}_Übersicht.pdf");
|
||||
var pdf = await PdfStatementService.GenerateDashboardStatementAsync(selectedYear);
|
||||
var suffix = selectedYear.HasValue ? $"_{selectedYear.Value}" : "_Gesamt";
|
||||
savedPdfPath = await FileSaveService.SaveFileAsync(pdf, $"{DisplayClubName}_Übersicht{suffix}.pdf");
|
||||
}
|
||||
|
||||
private void OpenYearFilterDialog()
|
||||
{
|
||||
showYearFilterDialog = true;
|
||||
}
|
||||
|
||||
private void CloseYearFilterDialog()
|
||||
{
|
||||
showYearFilterDialog = false;
|
||||
}
|
||||
|
||||
private async Task SelectFilterYear(int? year)
|
||||
{
|
||||
selectedYear = year;
|
||||
showYearFilterDialog = false;
|
||||
await LoadAll();
|
||||
}
|
||||
|
||||
private async Task HandleOpenSavedPdf()
|
||||
@@ -138,5 +165,7 @@ public partial class Dashboard
|
||||
return amount.ToString("N2", CultureInfo.GetCultureInfo("de-DE")) + " €";
|
||||
}
|
||||
|
||||
private string GetFilterLabel() => selectedYear?.ToString() ?? "Alle";
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user