Add Blazor application layer with UI components and pages
- Service interfaces and DTO models - Dashboard page with account overview - Account detail page with year/entry management - Reusable components: AccountCard, EntryTable, YearSelector - Dialog components: Add/Edit Account, Entry, Transfer, Year - Main layout and routing configuration
This commit is contained in:
16
src/Duempelkas.App/Components/Accounts/AccountCard.razor
Normal file
16
src/Duempelkas.App/Components/Accounts/AccountCard.razor
Normal file
@@ -0,0 +1,16 @@
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="card account-card h-100" @onclick="Navigate">
|
||||
<div class="card-body d-flex flex-column justify-content-between">
|
||||
<h5 class="card-title mb-3">@Account.Name</h5>
|
||||
<div class="@(Account.TotalBalance >= 0 ? "amount-positive" : "amount-negative") fs-4">
|
||||
@($"{Account.TotalBalance:N2} €")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public AccountSummaryDto Account { get; set; } = default!;
|
||||
|
||||
private void Navigate() => Navigation.NavigateTo($"/accounts/{Account.Id}");
|
||||
}
|
||||
12
src/Duempelkas.App/Components/Accounts/AccountCardList.razor
Normal file
12
src/Duempelkas.App/Components/Accounts/AccountCardList.razor
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="row g-3">
|
||||
@foreach (var account in Accounts)
|
||||
{
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<AccountCard Account="account" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public List<AccountSummaryDto> Accounts { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* AccountHeader is no longer used - header is now inline in AccountDetail.razor *@
|
||||
50
src/Duempelkas.App/Components/Accounts/EntryRow.razor
Normal file
50
src/Duempelkas.App/Components/Accounts/EntryRow.razor
Normal file
@@ -0,0 +1,50 @@
|
||||
<tr class="@GetRowClass()">
|
||||
<td>@Entry.DisplayId</td>
|
||||
<td>@Entry.Date.ToString("dd.MM.yyyy")</td>
|
||||
<td>
|
||||
@Entry.Title
|
||||
@if (Entry.IsTransfer && !string.IsNullOrEmpty(Entry.LinkedAccountName))
|
||||
{
|
||||
<small class="text-muted ms-1">
|
||||
(@(Entry.Type == EntryType.Expense ? "an" : "von") @Entry.LinkedAccountName)
|
||||
</small>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end @(Entry.Type == EntryType.Income ? "amount-positive" : "amount-negative")">
|
||||
@(Entry.Type == EntryType.Income ? "+" : "\u2212")@($"{Entry.Amount:N2} €")
|
||||
</td>
|
||||
<td>
|
||||
@if (Entry.IsDeleted)
|
||||
{
|
||||
<button class="btn btn-outline-success btn-sm" @onclick="() => OnRestore.InvokeAsync(Entry.Id)" title="Wiederherstellen">
|
||||
<i class="bi bi-arrow-counterclockwise"></i>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="() => OnEdit.InvokeAsync(Entry.Id)" title="Bearbeiten">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="() => OnDelete.InvokeAsync(Entry.Id)" title="Löschen">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@code {
|
||||
[Parameter] public EntryDto Entry { get; set; } = default!;
|
||||
[Parameter] public EventCallback<int> OnDelete { get; set; }
|
||||
[Parameter] public EventCallback<int> OnRestore { get; set; }
|
||||
[Parameter] public EventCallback<int> OnEdit { get; set; }
|
||||
|
||||
private string GetRowClass()
|
||||
{
|
||||
var classes = new List<string>();
|
||||
if (Entry.IsTransfer) classes.Add("entry-row-transfer");
|
||||
if (Entry.IsDeleted) classes.Add("entry-deleted");
|
||||
return string.Join(" ", classes);
|
||||
}
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Accounts/EntryTable.razor
Normal file
31
src/Duempelkas.App/Components/Accounts/EntryTable.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 100px;">LfdNr</th>
|
||||
<th style="width: 120px;">Datum</th>
|
||||
<th>Bezeichnung</th>
|
||||
<th style="width: 140px;" class="text-end">Betrag</th>
|
||||
<th style="width: 80px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var entry in Entries)
|
||||
{
|
||||
<EntryRow Entry="entry" OnDelete="OnDeleteEntry" OnRestore="OnRestoreEntry" OnEdit="OnEditEntry" />
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if (!Entries.Any())
|
||||
{
|
||||
<div class="text-center py-3 text-muted">Keine Einträge vorhanden.</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public List<EntryDto> Entries { get; set; } = new();
|
||||
[Parameter] public EventCallback<int> OnDeleteEntry { get; set; }
|
||||
[Parameter] public EventCallback<int> OnRestoreEntry { get; set; }
|
||||
[Parameter] public EventCallback<int> OnEditEntry { get; set; }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* ExportButton is no longer used - export is now inline in AccountDetail.razor *@
|
||||
@@ -0,0 +1 @@
|
||||
@* YearSelector is no longer used - year selection has been removed from the data model. *@
|
||||
13
src/Duempelkas.App/Components/App.razor
Normal file
13
src/Duempelkas.App/Components/App.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
<Router AppAssembly="@typeof(App).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<div class="container mt-5">
|
||||
<h3>Seite nicht gefunden</h3>
|
||||
<p>Die angeforderte Seite konnte nicht gefunden werden.</p>
|
||||
</div>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
29
src/Duempelkas.App/Components/Dialogs/AddAccountDialog.razor
Normal file
29
src/Duempelkas.App/Components/Dialogs/AddAccountDialog.razor
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Neues Konto</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kontoname</label>
|
||||
<input type="text" class="form-control" @bind="name" @bind:event="oninput"
|
||||
placeholder="z.B. Girokonto" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save" disabled="@string.IsNullOrWhiteSpace(name)"><i class="bi bi-check-lg"></i> Erstellen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public EventCallback<string> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private string name = string.Empty;
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
await OnSave.InvokeAsync(name.Trim());
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
70
src/Duempelkas.App/Components/Dialogs/AddEntryDialog.razor
Normal file
70
src/Duempelkas.App/Components/Dialogs/AddEntryDialog.razor
Normal file
@@ -0,0 +1,70 @@
|
||||
@inject IEntryService EntryService
|
||||
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5>@(EditEntry != null ? "Eintrag bearbeiten" : "Neuer Eintrag")</h5>
|
||||
@if (EditEntry == null)
|
||||
{
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Art</label>
|
||||
<select class="form-select" @bind="entryType">
|
||||
<option value="@EntryType.Income">Einnahme</option>
|
||||
<option value="@EntryType.Expense">Ausgabe</option>
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" @bind="date" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bezeichnung</label>
|
||||
<input type="text" class="form-control" @bind="title" placeholder="Beschreibung" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Betrag (€)</label>
|
||||
<input type="number" class="form-control" @bind="amount" step="0.01" min="0.01" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"
|
||||
disabled="@(string.IsNullOrWhiteSpace(title) || amount <= 0)">
|
||||
<i class="bi bi-check-lg"></i> @(EditEntry != null ? "Speichern" : "Hinzufügen")
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int AccountId { get; set; }
|
||||
[Parameter] public EntryDto? EditEntry { get; set; }
|
||||
[Parameter] public EventCallback OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private EntryType entryType = EntryType.Income;
|
||||
private DateTime date = DateTime.Today;
|
||||
private string title = string.Empty;
|
||||
private decimal amount;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
{
|
||||
entryType = EditEntry.Type;
|
||||
date = EditEntry.Date;
|
||||
title = EditEntry.Title;
|
||||
amount = EditEntry.Amount;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
await EntryService.UpdateEntryAsync(EditEntry.Id, date, title.Trim(), amount);
|
||||
else
|
||||
await EntryService.CreateEntryAsync(AccountId, entryType, date, title.Trim(), amount);
|
||||
await OnSave.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
@inject IEntryService EntryService
|
||||
@inject IAccountService AccountService
|
||||
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">@(EditEntry != null ? "Umbuchung bearbeiten" : "Neue Umbuchung")</h5>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Zielkonto</label>
|
||||
<select class="form-select" @bind="targetAccountId">
|
||||
<option value="0">— Auswählen —</option>
|
||||
@foreach (var acc in accounts.Where(a => a.Id != SourceAccountId))
|
||||
{
|
||||
<option value="@acc.Id">@acc.Name</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Datum</label>
|
||||
<input type="date" class="form-control" @bind="date" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bezeichnung</label>
|
||||
<input type="text" class="form-control" @bind="title" placeholder="Beschreibung der Umbuchung" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Betrag (€)</label>
|
||||
<input type="number" class="form-control" @bind="amount" step="0.01" min="0.01" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"
|
||||
disabled="@(!CanSave)"><i class="bi bi-arrow-left-right"></i> @(EditEntry != null ? "Speichern" : "Umbuchen")</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int SourceAccountId { get; set; }
|
||||
[Parameter] public EntryDto? EditEntry { get; set; }
|
||||
[Parameter] public EventCallback OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private List<AccountSummaryDto> accounts = new();
|
||||
private int targetAccountId;
|
||||
private DateTime date = DateTime.Today;
|
||||
private string title = string.Empty;
|
||||
private decimal amount;
|
||||
|
||||
private bool CanSave => targetAccountId > 0 && !string.IsNullOrWhiteSpace(title) && amount > 0;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (!accounts.Any())
|
||||
accounts = await AccountService.GetAllAccountsAsync();
|
||||
|
||||
if (EditEntry != null)
|
||||
{
|
||||
targetAccountId = EditEntry.LinkedAccountId ?? 0;
|
||||
date = EditEntry.Date;
|
||||
title = EditEntry.Title;
|
||||
amount = EditEntry.Amount;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (EditEntry != null)
|
||||
await EntryService.UpdateTransferAsync(EditEntry.Id, targetAccountId, date, title.Trim(), amount);
|
||||
else
|
||||
await EntryService.CreateTransferAsync(SourceAccountId, targetAccountId, date, title.Trim(), amount);
|
||||
await OnSave.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@* AddYearDialog is no longer used - year management has been removed from the data model. *@
|
||||
22
src/Duempelkas.App/Components/Dialogs/ConfirmDialog.razor
Normal file
22
src/Duempelkas.App/Components/Dialogs/ConfirmDialog.razor
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5>@Title</h5>
|
||||
<p>@Message</p>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> @CancelText</button>
|
||||
<button class="btn btn-danger" @onclick="Confirm"><i class="bi bi-trash"></i> @ConfirmText</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public string Title { get; set; } = "Bestätigung";
|
||||
[Parameter] public string Message { get; set; } = "Sind Sie sicher?";
|
||||
[Parameter] public string ConfirmText { get; set; } = "Ja, bestätigen";
|
||||
[Parameter] public string CancelText { get; set; } = "Nein, abbrechen";
|
||||
[Parameter] public EventCallback OnConfirm { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private async Task Confirm() => await OnConfirm.InvokeAsync();
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Übertrag bearbeiten</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Übertrag (€)</label>
|
||||
<input type="number" class="form-control" step="0.01" @bind="amount" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save"><i class="bi bi-check-lg"></i> Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public decimal CurrentAmount { get; set; }
|
||||
[Parameter] public EventCallback<decimal> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private decimal amount;
|
||||
|
||||
protected override void OnParametersSet() => amount = CurrentAmount;
|
||||
|
||||
private async Task Save() => await OnSave.InvokeAsync(amount);
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Dialogs/EditNameDialog.razor
Normal file
31
src/Duempelkas.App/Components/Dialogs/EditNameDialog.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="dialog-backdrop" @onclick="Cancel">
|
||||
<div class="dialog-content" @onclick:stopPropagation="true">
|
||||
<h5 class="mb-3">Kontoname bearbeiten</h5>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kontoname</label>
|
||||
<input type="text" class="form-control" @bind="name" @bind:event="oninput" />
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-outline-secondary" @onclick="Cancel"><i class="bi bi-x-lg"></i> Abbrechen</button>
|
||||
<button class="btn btn-primary" @onclick="Save" disabled="@string.IsNullOrWhiteSpace(name)"><i class="bi bi-check-lg"></i> Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public string CurrentName { get; set; } = string.Empty;
|
||||
[Parameter] public EventCallback<string> OnSave { get; set; }
|
||||
[Parameter] public EventCallback OnCancel { get; set; }
|
||||
|
||||
private string name = string.Empty;
|
||||
|
||||
protected override void OnParametersSet() => name = CurrentName;
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
await OnSave.InvokeAsync(name.Trim());
|
||||
}
|
||||
|
||||
private async Task Cancel() => await OnCancel.InvokeAsync();
|
||||
}
|
||||
31
src/Duempelkas.App/Components/Layout/MainLayout.razor
Normal file
31
src/Duempelkas.App/Components/Layout/MainLayout.razor
Normal file
@@ -0,0 +1,31 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="d-flex flex-column vh-100">
|
||||
<nav class="app-navbar d-flex justify-content-between align-items-center">
|
||||
<a class="navbar-brand" href="">
|
||||
<strong>Dümpelkas</strong> <small class="text-muted">Kassenbuch</small>
|
||||
</a>
|
||||
<span class="version-label">v@(AppVersion)</span>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1 overflow-auto p-3">
|
||||
@Body
|
||||
</main>
|
||||
|
||||
<footer class="app-footer">
|
||||
Dümpelkas © @DateTime.Now.Year · Version @AppVersion
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private static string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var yearShort = now.Year % 100;
|
||||
var dayOfYear = now.DayOfYear;
|
||||
return $"{yearShort}.{dayOfYear}";
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/Duempelkas.App/Components/Routes.razor
Normal file
10
src/Duempelkas.App/Components/Routes.razor
Normal file
@@ -0,0 +1,10 @@
|
||||
<Router AppAssembly="@typeof(Routes).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<LayoutView Layout="@typeof(MainLayout)">
|
||||
<p>Seite nicht gefunden.</p>
|
||||
</LayoutView>
|
||||
</NotFound>
|
||||
</Router>
|
||||
Reference in New Issue
Block a user