This commit is contained in:
1ilit
2023-09-19 15:50:04 +03:00
parent 44e179f15a
commit 21d01b1fe2
3 changed files with 781 additions and 317 deletions

View File

@@ -85,6 +85,7 @@ export default function Editor(props) {
notNull: true,
increment: true,
comment: "",
id: 0,
},
],
comment: "",
@@ -105,6 +106,22 @@ export default function Editor(props) {
}
};
const updateField = (tid, fid, updatedValues) => {
setTables((prev) =>
prev.map((table, i) => {
if (tid === i) {
return {
...table,
fields: table.fields.map((field, j) =>
fid === j ? { ...field, ...updatedValues } : field
),
};
}
return table;
})
);
};
const addArea = (addToHistory = true, data) => {
if (data) {
setAreas((prev) => {
@@ -325,7 +342,7 @@ export default function Editor(props) {
);
};
const editNote = (id, values, addToHistory=true) => {
const editNote = (id, values, addToHistory = true) => {
setNotes((prev) =>
prev.map((t) => {
if (t.id === id) {
@@ -337,7 +354,7 @@ export default function Editor(props) {
return t;
})
);
}
};
useEffect(() => {
document.title = "Editor - drawDB";
@@ -351,6 +368,7 @@ export default function Editor(props) {
setTables,
addTable,
moveTable,
updateField,
deleteTable,
relationships,
setRelationships,