Fixed save for diagrams

This commit is contained in:
1ilit 2023-11-01 13:35:57 +02:00
parent 092a08e624
commit 50d82fb435
2 changed files with 39 additions and 10 deletions

View File

@ -666,15 +666,29 @@ export default function ControlPanel({ diagramId, setDiagramId }) {
del(); del();
}; };
const save = () => { const save = () => {
db.diagrams.add({ if (diagramId === 0) {
name: title, db.diagrams
lastModified: new Date(), .add({
tables: tables, name: title,
references: relationships, lastModified: new Date(),
types: types, tables: tables,
notes: notes, references: relationships,
areas: areas, types: types,
}); notes: notes,
areas: areas,
})
.then((id) => setDiagramId(id));
} else {
db.diagrams.update(diagramId, {
name: title,
lastModified: new Date(),
tables: tables,
references: relationships,
types: types,
notes: notes,
areas: areas,
});
}
}; };
const open = () => setVisible(MODAL.OPEN); const open = () => setVisible(MODAL.OPEN);
const saveDiagramAs = () => setVisible(MODAL.SAVEAS); const saveDiagramAs = () => setVisible(MODAL.SAVEAS);
@ -1091,7 +1105,7 @@ export default function ControlPanel({ diagramId, setDiagramId }) {
case MODAL.IMPORT: case MODAL.IMPORT:
return "Import diagram"; return "Import diagram";
case MODAL.CODE: case MODAL.CODE:
return "Export diagram"; return "Export source";
case MODAL.IMG: case MODAL.IMG:
return "Export image"; return "Export image";
case MODAL.RENAME: case MODAL.RENAME:

View File

@ -5,6 +5,13 @@ import { AutoComplete, Button } from "@douyinfe/semi-ui";
import { IconSearch, IconSun, IconMoon } from "@douyinfe/semi-icons"; import { IconSearch, IconSun, IconMoon } from "@douyinfe/semi-icons";
const shortcuts = [ const shortcuts = [
{ shortcut: "CTRL+S", title: "Save diagram", description: "" },
{ shortcut: "CTRL+Shift+S", title: "Save diagram as", description: "" },
{
shortcut: "CTRL+O",
title: "Open a diagram",
description: "Load a saved diagram",
},
{ shortcut: "CTRL+C", title: "Copy selected element", description: "" }, { shortcut: "CTRL+C", title: "Copy selected element", description: "" },
{ shortcut: "CTRL+V", title: "Paste selected element", description: "" }, { shortcut: "CTRL+V", title: "Paste selected element", description: "" },
{ shortcut: "CTRL+X", title: "Cut selected element", description: "" }, { shortcut: "CTRL+X", title: "Cut selected element", description: "" },
@ -180,6 +187,14 @@ export default function Shortcuts() {
</div> </div>
))} ))}
</div> </div>
<hr
className={`${
theme === "dark" ? "border-zinc-700" : "border-zinc-300"
} my-1`}
/>
<div className="text-center text-sm py-3">
&copy; 2024 <strong>drawDB</strong> - All right reserved.
</div>
</> </>
); );
} }