Add JSON editor for the data files #7
Loading…
Reference in a new issue
No description provided.
Delete branch "json-editor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A new page Stammdaten → JSON-Editor (
/json-editor) for viewing and editing the data files of the year and mandator selected in the header, as plain JSON.Editor
Transactions.jsonby default; the dropdown offers the other six data files. The file is part of the URL (?file=).wwwroot/js/monaco.jsloads it only when the page opens, instead of three script tags on every page.Saving (
RawDataRepository)Only validated text is saved, because a broken file would break every page that reads it:
"Vlaue"), reported with line, column and path. Clicking an error jumps to the line.Id, and IDs must be unique.Transactions.jsonmay only reference accounts inAccounts.json;Accounts.jsonmay not drop accounts that transactions still use.backup/{mandator}/{year}/json-{timestamp}/.BaseRepository.SaveAsync: an atomic write that refreshes the cached data, so other pages see the change immediately. The file is written in the normal format; unchanged parts stay byte-identical.Infrastructure
Program.cs): the editor sends whole files from the browser (Transactions.jsonis several hundred KB), and the default is 32 KB per message.wwwroot/js/unsaved-guard.jsasks before leaving via a link, and the browser's own prompt covers reload, closing the tab and switching year or mandator. Blazor'sNavigationLockcan't do this here: pages are interactive one by one, so routing between them is static enhanced navigation, which doesn't consult interactive components. Switching files or "Neu laden" inside the page uses a Fluent confirmation dialog.Test plan
dotnet build: no warningsdotnet test: 98/98 pass, including 10 newRawDataRepositoryTestShouldtests:Transactions.jsonwith JSON highlighting; Ersetzen opens the replace widgetNotes
navmenu-toggleis null). The Fluent nav template expects a toggle element that this app doesn't render.🤖 Generated with Claude Code
New page Stammdaten -> JSON-Editor edits the data files of the selected year and mandator (default Transactions.json) as plain JSON in Monaco (BlazorMonaco 3.5.0, loaded on demand): highlighting, folding, live syntax errors, search and replace with regex, format. RawDataRepository saves only validated text: strict JSON (unknown properties rejected with line/column), unique non-empty Ids, transactions referencing existing accounts, accounts still used by transactions not removed. It refuses if the file changed since loading, backs up the previous version to backup/{mandator}/{year}/json-{timestamp}/, and saves through BaseRepository so caches are refreshed. - Hub MaximumReceiveMessageSize raised to 8 MB (files are several hundred KB) - unsaved-guard.js asks before leaving with unsaved changes; NavigationLock doesn't apply because routing between per-page interactive pages is static Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>