Fix save
This commit is contained in:
parent
0e041ed913
commit
2395a334bb
@ -176,6 +176,11 @@ export default function Templates() {
|
||||
newWindow.name = "t " + id;
|
||||
};
|
||||
|
||||
const forkTemplate = (id) => {
|
||||
const newWindow = window.open("/editor", "_blank");
|
||||
newWindow.name = "lt " + id;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.title = "Templates | drawDB";
|
||||
}, []);
|
||||
@ -225,7 +230,10 @@ export default function Templates() {
|
||||
<div className="text-lg font-bold text-zinc-700">
|
||||
{t.title}
|
||||
</div>
|
||||
<button className="border rounded px-2 py-1 bg-white hover:bg-gray-200 transition-all duration-300">
|
||||
<button
|
||||
className="border rounded px-2 py-1 bg-white hover:bg-gray-200 transition-all duration-300"
|
||||
onClick={() => forkTemplate(t.id)}
|
||||
>
|
||||
<i className="fa-solid fa-code-fork"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -252,7 +260,10 @@ export default function Templates() {
|
||||
{c.title}
|
||||
</div>
|
||||
<div>
|
||||
<button className="me-1 border rounded px-2 py-1 bg-white hover:bg-gray-200 transition-all duration-300">
|
||||
<button
|
||||
className="me-1 border rounded px-2 py-1 bg-white hover:bg-gray-200 transition-all duration-300"
|
||||
onClick={() => forkTemplate(c.id)}
|
||||
>
|
||||
<i className="fa-solid fa-code-fork"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -493,7 +493,10 @@ export default function Editor() {
|
||||
return;
|
||||
}
|
||||
if (diagram) {
|
||||
if (id === 0 && window.name === "") {
|
||||
if (
|
||||
(id === 0 && window.name === "") ||
|
||||
window.name.split(" ")[0] === "lt"
|
||||
) {
|
||||
db.diagrams
|
||||
.add({
|
||||
name: title,
|
||||
@ -547,7 +550,7 @@ export default function Editor() {
|
||||
};
|
||||
const name = window.name.split(" ");
|
||||
const op = name[0];
|
||||
const diagram = window.name === "" || op === "d";
|
||||
const diagram = window.name === "" || op === "d" || op === "lt";
|
||||
|
||||
save(diagram);
|
||||
}, [tables, relationships, notes, areas, types, title, id, state]);
|
||||
@ -635,7 +638,7 @@ export default function Editor() {
|
||||
break;
|
||||
}
|
||||
case "lt": {
|
||||
console.log("Loading template with id", did);
|
||||
loadTemplate(did);
|
||||
break;
|
||||
}
|
||||
case "t": {
|
||||
|
Loading…
Reference in New Issue
Block a user