Stammdaten -> Texte bereinigen shows the bookings of one account in the selected year and edits only their Text: inline, search and replace (plain or regex with $1 groups) over the listed rows, tidying spaces, or setting one text for selected rows. A group panel shows the first-word groups the Analyse page will use, updated live. Saving goes through RawDataRepository.SaveTransactionTextsAsync: refused if the file changed since loading or a text is empty, previous version backed up, atomic save. Opened from the menu, a button per account on Konten, and a link on the Analyse page at account level. Also: the content area fills the window between header and footer, so dropdowns on short pages are no longer cut off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
148 lines
7.4 KiB
Text
148 lines
7.4 KiB
Text
@page "/text-cleanup"
|
|
@rendermode InteractiveServer
|
|
|
|
<PageTitle>Texte bereinigen</PageTitle>
|
|
|
|
@if (snapshot is null)
|
|
{
|
|
<Loading/>
|
|
return;
|
|
}
|
|
|
|
<div class="cleanup">
|
|
<div class="toolbar">
|
|
<FluentSelect TOption="Account" Label="Konto" Width="280px" Height="360px"
|
|
Items="@accounts"
|
|
OptionText="@AccountLabel"
|
|
OptionValue="@(a => a.Number.ToString())"
|
|
Placeholder="Konto wählen…"
|
|
SelectedOption="@account"
|
|
SelectedOptionChanged="@OnAccountChanged"/>
|
|
<FluentSearch @bind-Value="filter" Immediate="true" Placeholder="Filter…" Style="width: 260px;"/>
|
|
<span class="year">Jahr @Year</span>
|
|
<span class="spacer"></span>
|
|
<FluentButton Appearance="Appearance.Accent" IconStart="@(new Icons.Regular.Size16.Save())"
|
|
Disabled="@(Dirty == false || saving)" Loading="@saving" OnClick="SaveAsync">
|
|
Speichern@(Dirty ? $" ({edits.Count})" : "")
|
|
</FluentButton>
|
|
<FluentButton Appearance="Appearance.Neutral" Disabled="@(Dirty == false)" OnClick="DiscardAsync">Verwerfen</FluentButton>
|
|
</div>
|
|
|
|
@* No early return here: it would leave this <div> unclosed (invalid render tree). *@
|
|
@if (account is null)
|
|
{
|
|
<FluentMessageBar Intent="MessageIntent.Info" AllowDismiss="false">Bitte ein Konto wählen.</FluentMessageBar>
|
|
}
|
|
else
|
|
{
|
|
|
|
<div class="tools">
|
|
<FluentTextField @bind-Value="find" Placeholder="Suchen" Style="width: 220px;" aria-label="Suchen"/>
|
|
<FluentTextField @bind-Value="replacement" Placeholder="Ersetzen durch" Style="width: 220px;" aria-label="Ersetzen durch"/>
|
|
<FluentCheckbox @bind-Value="useRegex" Label="Regex"/>
|
|
<FluentCheckbox @bind-Value="matchCase" Label="Gross/klein"/>
|
|
<FluentButton Appearance="Appearance.Neutral" IconStart="@(new Icons.Regular.Size16.ArrowSwap())"
|
|
OnClick="ReplaceAsync" title="In den angezeigten Texten ersetzen">Ersetzen</FluentButton>
|
|
<FluentButton Appearance="Appearance.Lightweight" OnClick="TidyAsync"
|
|
title="Leerzeichen am Anfang/Ende entfernen, doppelte zusammenfassen">Leerzeichen bereinigen</FluentButton>
|
|
</div>
|
|
|
|
@if (selected.Count > 0)
|
|
{
|
|
<div class="tools bulk">
|
|
<span>@selected.Count ausgewählt:</span>
|
|
<FluentTextField @bind-Value="bulkText" Placeholder="Neuer Text" Style="width: 260px;" aria-label="Neuer Text für die ausgewählten Buchungen"/>
|
|
<FluentButton Appearance="Appearance.Neutral" OnClick="SetSelectedTextAsync">Text setzen</FluentButton>
|
|
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => selected.Clear())">Auswahl aufheben</FluentButton>
|
|
</div>
|
|
}
|
|
|
|
@if (toolMessage is not null)
|
|
{
|
|
<div class="tool-message @(toolMessageIsError ? "error" : "")">@toolMessage</div>
|
|
}
|
|
|
|
@if (saveErrors.Count > 0)
|
|
{
|
|
<FluentMessageBar Intent="MessageIntent.Error" AllowDismiss="false" Title="Nicht gespeichert">
|
|
@foreach (var error in saveErrors)
|
|
{
|
|
<div>@error</div>
|
|
}
|
|
</FluentMessageBar>
|
|
}
|
|
|
|
<div class="main">
|
|
<FluentCard class="groups">
|
|
<div class="card-title">Gruppen (wie in der Analyse)</div>
|
|
<table>
|
|
<tbody>
|
|
@foreach (var group in Groups)
|
|
{
|
|
<tr @key="group.Name">
|
|
<td class="name">
|
|
<button type="button" class="link" title="Nach dieser Gruppe filtern" @onclick="@(() => FilterByGroup(group.Name))">@(string.IsNullOrEmpty(group.Name) ? "(ohne Text)" : group.Name)</button>
|
|
</td>
|
|
<td class="count">@group.Count</td>
|
|
<td class="amount">@Amount(group.Total)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</FluentCard>
|
|
|
|
<FluentCard class="rows">
|
|
<div class="card-title">
|
|
@AccountLabel(account): @VisibleRows.Count() von @rows.Count Buchungen@(Dirty ? $", {edits.Count} geändert" : "")
|
|
</div>
|
|
<div class="table-scroll">
|
|
<table class="bookings">
|
|
<thead>
|
|
<tr>
|
|
<th class="check">
|
|
<input type="checkbox" aria-label="Alle angezeigten auswählen" checked="@AllVisibleSelected"
|
|
@onchange="@(e => ToggleAllVisible((bool)e.Value!))"/>
|
|
</th>
|
|
<th>Datum</th>
|
|
<th class="amount">Betrag</th>
|
|
<th>Gegenkonto</th>
|
|
<th class="text">Text</th>
|
|
<th>Banktext</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var row in VisibleRows)
|
|
{
|
|
var t = row.Transaction;
|
|
<tr @key="t.Id" class="@(IsChanged(t) ? "changed" : "")">
|
|
<td class="check">
|
|
<input type="checkbox" aria-label="Auswählen" checked="@selected.Contains(t.Id)"
|
|
@onchange="@(e => ToggleSelected(t.Id, (bool)e.Value!))"/>
|
|
</td>
|
|
<td class="date">@t.ValueDate.ToString("dd.MM.yyyy")</td>
|
|
<td class="amount">@Amount(row.Amount)</td>
|
|
<td class="counter" title="@row.CounterAccount">@row.CounterAccount</td>
|
|
<td class="text">
|
|
<input type="text" value="@TextOf(t)" aria-label="Text"
|
|
@onchange="@(e => SetTextAsync(t, e.Value?.ToString() ?? ""))"/>
|
|
@if (IsChanged(t))
|
|
{
|
|
<div class="original" title="Bisheriger Text">@t.Text</div>
|
|
}
|
|
</td>
|
|
<td class="bank" title="@t.BankTransactionText">@t.BankTransactionText</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</FluentCard>
|
|
</div>
|
|
|
|
<div class="hint">
|
|
Ersetzen und „Leerzeichen bereinigen“ wirken auf die angezeigten Buchungen; mit dem Filter lässt sich das eingrenzen.
|
|
Regex: z.B. Suchen <code>^(.+) Luzern$</code>, Ersetzen <code>Luzern $1</code> macht aus „Migros Luzern“ „Luzern Migros“.
|
|
Gespeichert wird nur der Text; die bisherige Datei wird vorher unter backup/… gesichert.
|
|
</div>
|
|
}
|
|
</div>
|