Skip to content

Enable choosing file names for dfd and dd #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/features/serialize/saveDFDandDD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,20 @@ export class SaveDFDandDD {
* Method to save both XML files by creating Blob objects and triggering downloads.
*/
public saveDiagramAsDFD(): void {
this.saveFile(this.dfdString, ".dataflowdiagram");
this.saveFile(this.ddString, ".datadictionary");
const name = window.prompt("Enter file name:", getModelFileName());
this.saveFile(this.dfdString, ".dataflowdiagram", name);
this.saveFile(this.ddString, ".datadictionary", name);
}

private saveFile(file: string, ending: string) {
private saveFile(file: string, ending: string, name?: string | null): void {
const blob = new Blob([file], { type: "application/xml" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", getModelFileName() + ending);
if (!name) {
name = getModelFileName();
}
link.setAttribute("download", name + ending);
document.body.appendChild(link); // Append link to the body
link.click(); // Programmatically click to trigger download
URL.revokeObjectURL(url); // Revoke the URL after download
Expand Down