From 92a25596a1c2f42fb3d9e18bbe74141b5ee8c2b6 Mon Sep 17 00:00:00 2001 From: Francisco-Galindo Date: Tue, 14 Jan 2025 11:05:40 -0600 Subject: [PATCH] Add button to make a relationship a subtype --- src/components/EditorCanvas/Canvas.jsx | 1 + .../RelationshipsTab/RelationshipInfo.jsx | 39 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/components/EditorCanvas/Canvas.jsx b/src/components/EditorCanvas/Canvas.jsx index 2a67516..95665f2 100644 --- a/src/components/EditorCanvas/Canvas.jsx +++ b/src/components/EditorCanvas/Canvas.jsx @@ -435,6 +435,7 @@ export default function Canvas() { tables[linkingLine.startTableId].fields[linkingLine.startFieldId].name }_fk`, id: relationships.length, + subtype: false, }; delete newRelationship.startX; delete newRelationship.startY; diff --git a/src/components/EditorSidePanel/RelationshipsTab/RelationshipInfo.jsx b/src/components/EditorSidePanel/RelationshipsTab/RelationshipInfo.jsx index bc184f1..fcd21ae 100644 --- a/src/components/EditorSidePanel/RelationshipsTab/RelationshipInfo.jsx +++ b/src/components/EditorSidePanel/RelationshipsTab/RelationshipInfo.jsx @@ -1,4 +1,4 @@ -import { Row, Col, Select, Button, Popover, Table } from "@douyinfe/semi-ui"; +import { Row, Col, Select, Button, Popover, Table, Checkbox } from "@douyinfe/semi-ui"; import { IconDeleteStroked, IconLoopTextStroked, @@ -97,6 +97,30 @@ export default function RelationshipInfo({ data }) { ); }; + const toggleSubtype = () => { + const prevVal = data.subtype; + setUndoStack((prev) => [ + ...prev, + { + action: Action.EDIT, + element: ObjectType.RELATIONSHIP, + rid: data.id, + undo: { subtype: data.subtype }, + redo: { subtype: !data.subtype }, + message: t("edit_relationship", { + refName: data.name, + extra: "[subtype]", + }), + }, + ]); + setRedoStack([]); + setRelationships((prev) => + prev.map((e, idx) => + idx === data.id ? { ...e, subtype: !prevVal } : e, + ), + ); + }; + const changeConstraint = (key, value) => { const undoKey = `${key}Constraint`; setUndoStack((prev) => [ @@ -180,6 +204,19 @@ export default function RelationshipInfo({ data }) { className="w-full" onChange={changeCardinality} /> + + +
{'Subtype'}: +
+ + + + +
+ {console.log(data)}
{t("on_update")}: