Skip to content

Commit 9c7ff66

Browse files
authored
Fix imports and exports (#2183)
1 parent cd75659 commit 9c7ff66

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

static/js/generate_buttons.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function uuidv4() {
446446
);
447447
}
448448

449-
document.getElementById("import_settings").addEventListener("click", async function(event) {
449+
async function import_settings_string(event) {
450450
// Click event for importing settings from a string.
451451

452452
event.preventDefault();
@@ -552,6 +552,8 @@ document.getElementById("import_settings").addEventListener("click", async funct
552552
update_ui_states(null);
553553
savesettings();
554554
generateToast("Imported settings string.<br />All non-cosmetic settings have been overwritten.");
555-
});
555+
}
556+
557+
document.getElementById("import_settings").addEventListener("click", import_settings_string);
556558

557559
window["setup_pyodide"] = setup_pyodide;

static/js/utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ function download_json_file(jsonData, filename) {
55
jsonData (Object): The object containing the data to be downloaded.
66
filename (string): The name of the file to be downloaded.
77
*/
8-
9-
// Convert the JSON data to a string
10-
const jsonString = JSON.stringify(jsonData, null, 4);
8+
// Check if the jsonData is already a string, if not convert it to a string
9+
const jsonString = typeof jsonData === "string" ? jsonData : JSON.stringify(jsonData, null, 4);
1110

1211
// Create a Blob object representing the data as a JSON file
1312
const blob = new Blob([jsonString], { type: "application/json" });

ui/plando_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def export_plando_options(evt):
513513
plandoData = populate_plando_options(form, True)
514514
js.export_settings_string(None)
515515
plandoData["Settings String"] = js.settings_string.value
516-
js.download_json_file(plandoData, "plando_settings.json")
516+
js.download_json_file(json.dumps(plandoData), "plando_settings.json")
517517

518518

519519
@bind("change", "plando_starting_kongs_selected")

0 commit comments

Comments
 (0)