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>
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
// Loads the Monaco editor (shipped inside the BlazorMonaco package) on first use, so only the
|
|
// JSON editor page pays for it. BlazorMonaco normally expects three script tags in App.razor;
|
|
// this loads the same three in the same order.
|
|
|
|
let loading;
|
|
|
|
function loadScript(src) {
|
|
return new Promise((resolve, reject) => {
|
|
const script = document.createElement('script');
|
|
script.src = src;
|
|
script.onload = resolve;
|
|
script.onerror = () => reject(new Error(`${src} could not be loaded`));
|
|
document.head.appendChild(script);
|
|
});
|
|
}
|
|
|
|
export function ensureLoaded() {
|
|
loading ??= (async () => {
|
|
// Sets the AMD path config (var require = ...) and window.blazorMonaco.
|
|
await loadScript('_content/BlazorMonaco/jsInterop.js');
|
|
await loadScript('_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js');
|
|
await loadScript('_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js');
|
|
// editor.main registers itself as an AMD module; wait until it (and window.monaco) is ready.
|
|
await new Promise(resolve => window.require(['vs/editor/editor.main'], resolve));
|
|
})();
|
|
return loading;
|
|
}
|