diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsx
index ec133be..60bb45b 100644
--- a/src/components/control_panel.jsx
+++ b/src/components/control_panel.jsx
@@ -195,19 +195,11 @@ export default function ControlPanel(props) {
} else if (a.component === "comment") {
updateTable(a.tid, a.undo, false);
} else if (a.component === "index_add") {
- setTables((prev) =>
- prev.map((table, i) => {
- if (table.id === a.tid) {
- return {
- ...table,
- indices: table.indices
- .filter((e) => e.id !== tables[a.tid].indices.length - 1)
- .map((t, i) => ({ ...t, id: i })),
- };
- }
- return table;
- })
- );
+ updateTable(a.tid, {
+ indices: tables[a.tid].indices
+ .filter((e) => e.id !== tables[a.tid].indices.length - 1)
+ .map((t, i) => ({ ...t, id: i })),
+ });
} else if (a.component === "index") {
updateTable(a.tid, {
indices: tables[a.tid].indices.map((index) =>
@@ -236,6 +228,10 @@ export default function ControlPanel(props) {
} else if (a.component === "self") {
updateTable(a.tid, a.undo);
}
+ } else if (a.element === ObjectType.RELATIONSHIP) {
+ setRelationships((prev) =>
+ prev.map((e, idx) => (idx === a.rid ? { ...e, ...a.undo } : e))
+ );
}
setRedoStack((prev) => [...prev, a]);
} else if (a.action === Action.PAN) {
@@ -365,6 +361,10 @@ export default function ControlPanel(props) {
} else if (a.component === "self") {
updateTable(a.tid, a.redo);
}
+ } else if (a.element === ObjectType.RELATIONSHIP) {
+ setRelationships((prev) =>
+ prev.map((e, idx) => (idx === a.rid ? { ...e, ...a.redo } : e))
+ );
}
setUndoStack((prev) => [...prev, a]);
} else if (a.action === Action.PAN) {
@@ -1105,7 +1105,7 @@ export default function ControlPanel(props) {
!exportData.data),
}}
cancelText="Cancel"
- width={540}
+ width={600}
>
{visible === MODAL.IMPORT ? (
diff --git a/src/components/reference_overview.jsx b/src/components/reference_overview.jsx
index 8a33aaf..06776cf 100644
--- a/src/components/reference_overview.jsx
+++ b/src/components/reference_overview.jsx
@@ -3,9 +3,9 @@ import {
AutoComplete,
Collapse,
Empty,
- Form,
Row,
Col,
+ Select,
Button,
Checkbox,
Popover,
@@ -22,8 +22,8 @@ import {
IllustrationNoContent,
IllustrationNoContentDark,
} from "@douyinfe/semi-illustrations";
-import { Cardinality, Constraint } from "../data/data";
-import { TableContext } from "../pages/editor";
+import { Cardinality, Constraint, Action, ObjectType } from "../data/data";
+import { TableContext, UndoRedoContext } from "../pages/editor";
export default function ReferenceOverview(props) {
const columns = [
@@ -38,6 +38,7 @@ export default function ReferenceOverview(props) {
];
const { tables, relationships, setRelationships, deleteRelationship } =
useContext(TableContext);
+ const { setUndoStack, setRedoStack } = useContext(UndoRedoContext);
const [refActiveIndex, setRefActiveIndex] = useState("");
const [value, setValue] = useState("");
const [filteredResult, setFilteredResult] = useState(
@@ -99,126 +100,177 @@ export default function ReferenceOverview(props) {
relationships.map((r, i) => (
{r.name}
} itemKey={`${i}`}>
-
+ Cardinality
+