## Summary
A new page **Stammdaten → Texte bereinigen** (`/text-cleanup?acc=<number>`) to view and clean the booking texts of one account, e.g. "Ferien", in the year selected in the header.
Scope, as agreed: one account, the selected year, **only the `Text` field**, only existing bookings. Booking rules and the booking-text list are not touched.
### Page
- **Account dropdown**, filter, and a table of all bookings of the account (both sides, so refunds are negative): date, amount, counter account, the **editable text**, and the bank text as a read-only hint.
- **Group panel:** the texts grouped by first word, exactly as the Analyse page groups them, with count and total. It updates live while editing, and clicking a group filters the table.
- **Tools, acting on the rows currently shown** (the filter limits their reach):
- **Search and replace:** plain text, or regex with `$1` groups. For example `^(.+) Luzern$` → `Luzern $1` turns "Migros Luzern" into "Luzern Migros".
- **Leerzeichen bereinigen:** trims and collapses repeated spaces.
- **Several rows at once:** checkboxes plus "Text setzen" give selected rows one text.
- **Changes:** changed rows are highlighted, with the old text crossed out underneath. Nothing is written until **Speichern (n)**; **Verwerfen** discards.
- **Unsaved changes:** leaving the page asks first (same `unsaved-guard.js` as the JSON editor).
- **Entry points:** the menu, a new button per account on **Konten**, and a "Texte <Jahr> bereinigen" link on the **Analyse** page at account level.
### Saving
`RawDataRepository.SaveTransactionTextsAsync` changes only the `Text` of the given bookings (by ID):
- refused if the file changed since loading (SHA-256), if a text is empty, or if a booking no longer exists;
- the previous version is backed up to `backup/{mandator}/{year}/json-{timestamp}/`, then saved atomically through `BaseRepository`, so cached data is refreshed;
- the file is read once, so the backup is exactly the version that was checked.
`TextReplacement` (Services) holds the search and replace logic:
- plain search is literal, including a `$` in the replacement;
- regex has a 500 ms timeout against runaway patterns;
- invalid patterns give a German error message.
### Layout fix (app-wide)
The content area (`.body-content`) scrolls its own content and was only as tall as the page, so on short pages open dropdowns were cut off after a line or two. It now fills at least the window between header and footer (`app.css`). On short pages the footer therefore sits at the bottom of the window. The account list is also limited to 360 px and scrolls.
## Test plan
- [x] `dotnet build`: no warnings
- [x] `dotnet test`: 111/111 pass, including 13 new tests:
- 5 `RawDataRepositoryTestShould`: load with hash, only Text changes plus backup, empty text refused, unknown booking refused, changed file refused
- 8 `TextReplacementTestShould`: case handling, literal special characters, regex groups, no match, invalid regex, empty search, tidy
- [x] Headless Chrome on a copy of the real data, Ferien account (21 bookings in 2026):
- "Mailand" → "Milano" via replace, 1 direct edit, and 3 rows set via "Text setzen"; the group panel showed "Milano" before saving
- after saving, exactly those 7 texts changed on disk, no other field of any booking, and a backup was written
- [x] Opening the page without an account: hint shown, no render error. An early `return` inside an element first caused "A frame of type 'Element' was left unclosed"; fixed and checked.
- [x] Account dropdown on the empty page opens fully (360 px, scrollable) within the content area
- [x] Links from Konten and Analyse open the page with the account preselected
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: #8
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
325 lines
4.8 KiB
CSS
325 lines
4.8 KiB
CSS
.analytics {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
}
|
|
|
|
.toolbar {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: flex-end;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
}
|
|
|
|
.filters {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: flex-end;
|
|
gap: 8px;
|
|
}
|
|
|
|
.segmented {
|
|
display: flex;
|
|
gap: 2px;
|
|
margin-left: 8px;
|
|
}
|
|
|
|
.kpis {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 12px;
|
|
}
|
|
|
|
::deep .kpi {
|
|
padding: 14px 16px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.kpi-label {
|
|
color: #52514e;
|
|
font-size: 12px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.04em;
|
|
}
|
|
|
|
.kpi-value {
|
|
font-size: 24px;
|
|
/* Fluent sets a fixed 20px line height; at 24px the descenders (g, p, y) would stick out of
|
|
the box and get cut where the text is truncated with an ellipsis. */
|
|
line-height: 1.3;
|
|
font-weight: 600;
|
|
margin: 4px 0 2px;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.kpi-name,
|
|
.ellipsis {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.kpi-value.worse {
|
|
color: #c50f1f;
|
|
}
|
|
|
|
.kpi-value.better {
|
|
color: #107c10;
|
|
}
|
|
|
|
.kpi-sub {
|
|
color: #52514e;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.main {
|
|
display: grid;
|
|
grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
|
|
gap: 12px;
|
|
align-items: start;
|
|
}
|
|
|
|
@media (max-width: 1100px) {
|
|
.main {
|
|
grid-template-columns: minmax(0, 1fr);
|
|
}
|
|
}
|
|
|
|
::deep .chart-card,
|
|
::deep .list-card {
|
|
padding: 16px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.card-title {
|
|
font-weight: 600;
|
|
font-size: 15px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.hint,
|
|
.empty {
|
|
color: #52514e;
|
|
font-size: 12px;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.categories {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.categories td {
|
|
padding: 6px 4px;
|
|
border-bottom: 1px solid #e1e0d9;
|
|
vertical-align: top;
|
|
}
|
|
|
|
.categories tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.swatch-cell {
|
|
width: 14px;
|
|
}
|
|
|
|
.swatch {
|
|
display: inline-block;
|
|
width: 10px;
|
|
height: 10px;
|
|
border-radius: 3px;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.name a {
|
|
color: inherit;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.name a:hover,
|
|
.name a:focus-visible {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.share-bar {
|
|
height: 4px;
|
|
background: #f0efea;
|
|
border-radius: 2px;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.share-bar > div {
|
|
height: 100%;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.amount {
|
|
text-align: right;
|
|
white-space: nowrap;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.share {
|
|
color: #52514e;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.pair {
|
|
display: grid;
|
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
gap: 12px;
|
|
}
|
|
|
|
@media (max-width: 1100px) {
|
|
.pair {
|
|
grid-template-columns: minmax(0, 1fr);
|
|
}
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.card-header .card-title {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.segmented.small {
|
|
margin-left: 0;
|
|
}
|
|
|
|
::deep .table-card {
|
|
padding: 16px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.table-scroll {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.years {
|
|
width: 100%;
|
|
border-collapse: separate;
|
|
border-spacing: 2px;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.years th,
|
|
.years td {
|
|
padding: 6px 8px;
|
|
text-align: right;
|
|
white-space: nowrap;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.years thead th {
|
|
color: #52514e;
|
|
font-weight: 600;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.years .name {
|
|
text-align: left;
|
|
font-weight: normal;
|
|
max-width: 280px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.years thead .name {
|
|
font-weight: 600;
|
|
}
|
|
|
|
.years .name a {
|
|
color: inherit;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.years .name a:hover,
|
|
.years .name a:focus-visible {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.years .total {
|
|
font-weight: 600;
|
|
border-left: 1px solid #e1e0d9;
|
|
}
|
|
|
|
.years tfoot th,
|
|
.years tfoot td {
|
|
font-weight: 600;
|
|
border-top: 1px solid #e1e0d9;
|
|
}
|
|
|
|
.years .zero {
|
|
color: #c4c3be;
|
|
}
|
|
|
|
.change {
|
|
font-size: 11px;
|
|
color: #52514e;
|
|
min-height: 14px;
|
|
}
|
|
|
|
.change.worse {
|
|
color: #c50f1f;
|
|
}
|
|
|
|
.change.better {
|
|
color: #107c10;
|
|
}
|
|
|
|
.segmented.views {
|
|
margin-left: 0;
|
|
}
|
|
|
|
/* Narrow screens: button groups and the category list wrap instead of widening the page. */
|
|
.segmented {
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.categories .name {
|
|
overflow-wrap: anywhere;
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
.segmented {
|
|
margin-left: 0;
|
|
}
|
|
|
|
.kpis {
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
}
|
|
|
|
.kpi-value {
|
|
font-size: 20px;
|
|
}
|
|
}
|
|
|
|
/* Year table on a phone: a narrow name column that stays in place while the years scroll. */
|
|
@media (max-width: 600px) {
|
|
.years .name {
|
|
max-width: 120px;
|
|
position: sticky;
|
|
left: 0;
|
|
z-index: 1;
|
|
background: #ffffff;
|
|
}
|
|
}
|
|
|
|
.crumbs {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
gap: 6px 16px;
|
|
}
|
|
|
|
.cleanup-link {
|
|
font-size: 13px;
|
|
}
|