Add optional export filename, tests for post-implement features
Add optional filename field to export dialog with automatic .json extension handling. Extract resolveFilename() for testability. Add tests for includeHistory flag, bundleToJson, and filename resolution. Add export format compatibility note to CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -84,12 +84,18 @@ export function bundleToJson(bundle: ExportBundle): string {
|
||||
return JSON.stringify(bundle, null, 2);
|
||||
}
|
||||
|
||||
export function triggerDownload(bundle: ExportBundle): void {
|
||||
export function resolveFilename(name?: string): string {
|
||||
const base =
|
||||
name?.trim() ||
|
||||
`initiative-export-${new Date().toISOString().slice(0, 10)}`;
|
||||
return base.endsWith(".json") ? base : `${base}.json`;
|
||||
}
|
||||
|
||||
export function triggerDownload(bundle: ExportBundle, name?: string): void {
|
||||
const blob = new Blob([bundleToJson(bundle)], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const date = new Date().toISOString().slice(0, 10);
|
||||
const filename = `initiative-export-${date}.json`;
|
||||
const filename = resolveFilename(name);
|
||||
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = url;
|
||||
|
||||
Reference in New Issue
Block a user