Add Save as template

This commit is contained in:
1ilit
2023-12-19 04:36:10 +02:00
parent c5f929ac55
commit dec6362fa9
11 changed files with 78 additions and 26 deletions

View File

@@ -729,6 +729,23 @@ export default function ControlPanel({
function: saveDiagramAs,
shortcut: "Ctrl+Shift+S",
},
"Save as template": {
function: () => {
db.templates
.add({
title: title,
tables: tables,
relationships: relationships,
types: types,
notes: notes,
subjectAreas: areas,
custom: 1,
})
.then(() => {
Toast.success("Template saved!");
});
},
},
Share: {
function: () => {},
},
@@ -756,18 +773,6 @@ export default function ControlPanel({
.catch(() => Toast.error("Oops! Something went wrong."));
},
},
"Flush storage": {
function: async () => {
db.delete()
.then(() => {
Toast.success("Storage flushed");
window.location.reload(false);
})
.catch(() => {
Toast.error("Oops! Something went wrong.");
});
},
},
Import: {
function: fileImport,
shortcut: "Ctrl+I",
@@ -935,6 +940,18 @@ export default function ControlPanel({
return { ...prev, panning: !prev.panning };
}),
},
{
"Flush storage": async () => {
db.delete()
.then(() => {
Toast.success("Storage flushed");
window.location.reload(false);
})
.catch(() => {
Toast.error("Oops! Something went wrong.");
});
},
},
],
},
Exit: {