From 12e18ae23529a64e1fe76fadeb7057fa64c79839 Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Mon, 12 Oct 2026 07:53:36 -0400 Subject: [PATCH] Align Recheck button with balance inputs; add table sort/filter/search - Recheck Balance now lines up with the balance input fields on wide viewports via an invisible label-height spacer, instead of the row's top edge. - Each transaction column gets its own up/down sort arrows, plus a filter row beneath the header (Description doubles as search, Status is a dropdown of values actually present). Sorting/filtering never disturbs row identity - edits and flags still target the original index, not the displayed position. --- CLAUDE.md | 28 ++++++- frontend/src/assets/main.css | 37 +++++++++ frontend/src/components/TransactionsTable.vue | 81 ++++++++++++++++--- .../src/composables/useTransactionFilters.js | 76 +++++++++++++++++ 4 files changed, 208 insertions(+), 14 deletions(-) create mode 100644 frontend/src/composables/useTransactionFilters.js diff --git a/CLAUDE.md b/CLAUDE.md index 8aa4348..44fb7de 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -616,7 +616,33 @@ restructure; the behavior itself predates it and is unchanged: "not_available" (its detail — "No opening and/or closing balance available..." — already reads as a complete sentence) — both outcomes used to leave the readout silently grey with no explanation; "not_available"'s case was only noticed and fixed 2026-10-12, after "fail" - already had it. + already had it. On wide viewports the button is wrapped in `.recheck-wrap` with an + invisible `.recheck-spacer` label above it mirroring `.fields label`'s own box (same + font-size/margin-bottom) — this is what lines the button's top edge up with the balance + inputs' own top edge rather than the row's labels, without a hardcoded pixel offset that + would drift if the label style ever changes. The spacer is hidden at the 640px mobile + breakpoint, where the button drops below the fields instead (see above). +- Sort + filter/search on the transactions table (`TransactionsTable.vue` + + `useTransactionFilters.js`, added 2026-10-12) — purely client-side display state, no + backend involvement, same scope as `useImageZoom.js`. Each sortable header (Date, + Description, Amount, Balance, Status) gets its own up/down arrow pair + (`.sort-arrows`/`.sort-arrow`) rather than one toggle arrow, so both directions stay + visible; the active column+direction turns blue. A second `` + sits inside ``, directly beneath the header row (so it inherits the same + `colgroup` widths via `table-layout:fixed`) — free-text filter inputs per column + (Description's doubles as the search box), Status as an exact-match ` + + + + + + + + No transactions match the current filters. + diff --git a/frontend/src/composables/useTransactionFilters.js b/frontend/src/composables/useTransactionFilters.js new file mode 100644 index 0000000..c8b0f43 --- /dev/null +++ b/frontend/src/composables/useTransactionFilters.js @@ -0,0 +1,76 @@ +/** + * Client-side sort + per-column filter/search over the transactions table. + * Pure UI state, no service calls - mirrors useImageZoom.js's own scope. + * + * Operates on {index, transaction} pairs rather than the transaction list + * directly, and always returns the ORIGINAL index (position in + * currentResult.transactions) alongside each visible row - TransactionRow + * reads/writes the store by that index, so sorting or filtering the + * DISPLAY order must never change which index a row actually points to. + */ +import { ref, computed } from 'vue' + +const FILTERABLE_FIELDS = ['date', 'description', 'amount', 'balance', 'status'] + +function compareValues(a, b, key) { + if (key === 'amount' || key === 'balance') { + return (a ?? 0) - (b ?? 0) + } + if (key === 'date') { + const at = Date.parse(a) + const bt = Date.parse(b) + if (!Number.isNaN(at) && !Number.isNaN(bt)) return at - bt + } + return String(a ?? '').localeCompare(String(b ?? '')) +} + +export function useTransactionFilters(transactionsRef) { + const sortKey = ref(null) + const sortDir = ref('asc') + const filters = ref({ date: '', description: '', amount: '', balance: '', status: '' }) + + function setSort(key, dir) { + sortKey.value = key + sortDir.value = dir + } + + function clearFilters() { + filters.value = { date: '', description: '', amount: '', balance: '', status: '' } + } + + const hasActiveFilters = computed(() => Object.values(filters.value).some((v) => v !== '')) + + // Status is filtered via an exact-match dropdown (a small enum), not free + // text like the other columns - populated from whatever values are + // actually present, so it never offers a status this statement doesn't have. + const statusOptions = computed(() => { + const seen = new Set() + for (const t of transactionsRef.value || []) { + if (t.status) seen.add(t.status) + } + return [...seen].sort() + }) + + const visibleRows = computed(() => { + let rows = (transactionsRef.value || []).map((transaction, index) => ({ transaction, index })) + + rows = rows.filter(({ transaction }) => + FILTERABLE_FIELDS.every((key) => { + const filterValue = filters.value[key] + if (!filterValue) return true + if (key === 'status') return transaction.status === filterValue + return String(transaction[key] ?? '').toLowerCase().includes(filterValue.toLowerCase()) + }), + ) + + if (sortKey.value) { + const dir = sortDir.value === 'asc' ? 1 : -1 + const key = sortKey.value + rows = [...rows].sort((a, b) => compareValues(a.transaction[key], b.transaction[key], key) * dir) + } + + return rows + }) + + return { sortKey, sortDir, setSort, filters, clearFilters, hasActiveFilters, statusOptions, visibleRows } +}