mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 10:29:11 +00:00
Add button to make a relationship a subtype
This commit is contained in:
parent
3ac309e073
commit
92a25596a1
@ -435,6 +435,7 @@ export default function Canvas() {
|
|||||||
tables[linkingLine.startTableId].fields[linkingLine.startFieldId].name
|
tables[linkingLine.startTableId].fields[linkingLine.startFieldId].name
|
||||||
}_fk`,
|
}_fk`,
|
||||||
id: relationships.length,
|
id: relationships.length,
|
||||||
|
subtype: false,
|
||||||
};
|
};
|
||||||
delete newRelationship.startX;
|
delete newRelationship.startX;
|
||||||
delete newRelationship.startY;
|
delete newRelationship.startY;
|
||||||
|
@ -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 {
|
import {
|
||||||
IconDeleteStroked,
|
IconDeleteStroked,
|
||||||
IconLoopTextStroked,
|
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 changeConstraint = (key, value) => {
|
||||||
const undoKey = `${key}Constraint`;
|
const undoKey = `${key}Constraint`;
|
||||||
setUndoStack((prev) => [
|
setUndoStack((prev) => [
|
||||||
@ -180,6 +204,19 @@ export default function RelationshipInfo({ data }) {
|
|||||||
className="w-full"
|
className="w-full"
|
||||||
onChange={changeCardinality}
|
onChange={changeCardinality}
|
||||||
/>
|
/>
|
||||||
|
<Row gutter={6} className="my-3">
|
||||||
|
<Col span={12}>
|
||||||
|
<div className="font-semibold my-1" >{'Subtype'}:
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<Checkbox
|
||||||
|
checked={data.subtype}
|
||||||
|
onChange={toggleSubtype}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
{console.log(data)}
|
||||||
<Row gutter={6} className="my-3">
|
<Row gutter={6} className="my-3">
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<div className="font-semibold">{t("on_update")}: </div>
|
<div className="font-semibold">{t("on_update")}: </div>
|
||||||
|
Loading…
Reference in New Issue
Block a user