mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 10:29:11 +00:00
Add subtype restrictions
This commit is contained in:
parent
92a25596a1
commit
08a9ff2803
@ -436,6 +436,7 @@ export default function Canvas() {
|
|||||||
}_fk`,
|
}_fk`,
|
||||||
id: relationships.length,
|
id: relationships.length,
|
||||||
subtype: false,
|
subtype: false,
|
||||||
|
subtype_restriction: "",
|
||||||
};
|
};
|
||||||
delete newRelationship.startX;
|
delete newRelationship.startX;
|
||||||
delete newRelationship.startY;
|
delete newRelationship.startY;
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
} from "@douyinfe/semi-icons";
|
} from "@douyinfe/semi-icons";
|
||||||
import {
|
import {
|
||||||
Cardinality,
|
Cardinality,
|
||||||
|
SubtypeRestriction,
|
||||||
Constraint,
|
Constraint,
|
||||||
Action,
|
Action,
|
||||||
ObjectType,
|
ObjectType,
|
||||||
@ -97,6 +98,29 @@ export default function RelationshipInfo({ data }) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const changeSubtypeRestriction = (value) => {
|
||||||
|
setUndoStack((prev) => [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
|
action: Action.EDIT,
|
||||||
|
element: ObjectType.RELATIONSHIP,
|
||||||
|
rid: data.id,
|
||||||
|
undo: { subtype_restriction: data.subtype_restriction },
|
||||||
|
redo: { subtype_restriction: value },
|
||||||
|
message: t("edit_relationship", {
|
||||||
|
refName: data.name,
|
||||||
|
extra: "[subtype_restriction]",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
setRedoStack([]);
|
||||||
|
setRelationships((prev) =>
|
||||||
|
prev.map((e, idx) =>
|
||||||
|
idx === data.id ? { ...e, subtype_restriction: value } : e,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const toggleSubtype = () => {
|
const toggleSubtype = () => {
|
||||||
const prevVal = data.subtype;
|
const prevVal = data.subtype;
|
||||||
setUndoStack((prev) => [
|
setUndoStack((prev) => [
|
||||||
@ -206,7 +230,7 @@ export default function RelationshipInfo({ data }) {
|
|||||||
/>
|
/>
|
||||||
<Row gutter={6} className="my-3">
|
<Row gutter={6} className="my-3">
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<div className="font-semibold my-1" >{'Subtype'}:
|
<div className="font-semibold my-1" >{t("subtype")}:
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
@ -216,7 +240,20 @@ export default function RelationshipInfo({ data }) {
|
|||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{console.log(data)}
|
{data.subtype &&
|
||||||
|
<Row gutter={6} className="my-3">
|
||||||
|
<div className="font-semibold my-1">{t("subtype_restriction")}:</div>
|
||||||
|
<Select
|
||||||
|
optionList={Object.values(SubtypeRestriction).map((v) => ({
|
||||||
|
label: t(v),
|
||||||
|
value: v,
|
||||||
|
}))}
|
||||||
|
value={data.subtype_restriction}
|
||||||
|
className="w-full"
|
||||||
|
onChange={changeSubtypeRestriction}
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
}
|
||||||
<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>
|
||||||
|
@ -34,6 +34,13 @@ export const Cardinality = {
|
|||||||
MANY_TO_ONE: "many_to_one",
|
MANY_TO_ONE: "many_to_one",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const SubtypeRestriction = {
|
||||||
|
DISJOINT_TOTAL: "disjoint_total",
|
||||||
|
DISJOINT_PARTIAL: "disjoint_partial",
|
||||||
|
OVERLAPPING_TOTAL: "overlapping_total",
|
||||||
|
OVERLAPPING_PARTIAL: "overlapping_partial",
|
||||||
|
};
|
||||||
|
|
||||||
export const Constraint = {
|
export const Constraint = {
|
||||||
NONE: "No action",
|
NONE: "No action",
|
||||||
RESTRICT: "Restrict",
|
RESTRICT: "Restrict",
|
||||||
|
@ -52,6 +52,12 @@ const en = {
|
|||||||
default_notation: "Default notation",
|
default_notation: "Default notation",
|
||||||
crows_foot_notation: "Crow's foot notation",
|
crows_foot_notation: "Crow's foot notation",
|
||||||
idef1x_notation: "IDEF1X notation",
|
idef1x_notation: "IDEF1X notation",
|
||||||
|
subtype: "Subtype",
|
||||||
|
subtype_restriction: "Subtype restriction",
|
||||||
|
disjoint_partial: "Disjoint partial",
|
||||||
|
disjoint_total: "Disjoint total",
|
||||||
|
overlapping_partial: "Overlapping partial",
|
||||||
|
overlapping_total: "Overlapping total",
|
||||||
notation: "Notation",
|
notation: "Notation",
|
||||||
theme: "Theme",
|
theme: "Theme",
|
||||||
light: "Light",
|
light: "Light",
|
||||||
|
@ -53,6 +53,12 @@ const es = {
|
|||||||
default_notation: "Notación predeterminada",
|
default_notation: "Notación predeterminada",
|
||||||
crows_foot_notation: "Notación Crow's Foot",
|
crows_foot_notation: "Notación Crow's Foot",
|
||||||
idef1x_notation: "Notación IDEF1X",
|
idef1x_notation: "Notación IDEF1X",
|
||||||
|
subtype: "Subtipo",
|
||||||
|
subtype_restriction: "Restricción de subtipo",
|
||||||
|
disjoint_partial: "Excluyente parcial",
|
||||||
|
disjoint_total: "Excluyente total",
|
||||||
|
overlapping_partial: "Traslape partial",
|
||||||
|
overlapping_total: "Traslape total",
|
||||||
theme: "Tema",
|
theme: "Tema",
|
||||||
light: "Claro",
|
light: "Claro",
|
||||||
dark: "Oscuro",
|
dark: "Oscuro",
|
||||||
|
Loading…
Reference in New Issue
Block a user