mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 10:29:11 +00:00
change to zero_to_many
This commit is contained in:
parent
92a25596a1
commit
a2911aad07
26
package-lock.json
generated
26
package-lock.json
generated
@ -15,7 +15,6 @@
|
||||
"@uiw/codemirror-theme-github": "^4.21.25",
|
||||
"@uiw/codemirror-theme-vscode": "^4.21.25",
|
||||
"@uiw/react-codemirror": "^4.21.25",
|
||||
"@vercel/analytics": "^1.2.2",
|
||||
"axios": "^1.7.4",
|
||||
"classnames": "^2.5.1",
|
||||
"dexie": "^3.2.4",
|
||||
@ -2253,26 +2252,6 @@
|
||||
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@vercel/analytics": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/analytics/-/analytics-1.2.2.tgz",
|
||||
"integrity": "sha512-X0rctVWkQV1e5Y300ehVNqpOfSOufo7ieA5PIdna8yX/U7Vjz0GFsGf4qvAhxV02uQ2CVt7GYcrFfddXXK2Y4A==",
|
||||
"dependencies": {
|
||||
"server-only": "^0.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"next": ">= 13",
|
||||
"react": "^18 || ^19"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"next": {
|
||||
"optional": true
|
||||
},
|
||||
"react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@vitejs/plugin-react": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.2.1.tgz",
|
||||
@ -5816,11 +5795,6 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/server-only": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/server-only/-/server-only-0.0.1.tgz",
|
||||
"integrity": "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA=="
|
||||
},
|
||||
"node_modules/set-function-length": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz",
|
||||
|
@ -5,7 +5,7 @@ import { useDiagram, useSettings, useLayout, useSelect } from "../../hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { SideSheet } from "@douyinfe/semi-ui";
|
||||
import RelationshipInfo from "../EditorSidePanel/RelationshipsTab/RelationshipInfo";
|
||||
import { CrowOM, CrowOO, CrowZM, IDEFZM, DefaultNotation } from "./RelationshipFormat";
|
||||
import { CrowOM, CrowOO, CrowZM, IDEFZM, DefaultNotation, sub01 } from "./RelationshipFormat";
|
||||
|
||||
|
||||
export default function Relationship({ data }) {
|
||||
@ -16,7 +16,7 @@ export default function Relationship({ data }) {
|
||||
const { t } = useTranslation();
|
||||
const pathRef = useRef();
|
||||
const type = settings.notation === 'default' ? 0 : 10;
|
||||
const relationshipType=(5,type);
|
||||
const relationshipType=(0,0);
|
||||
|
||||
let direction = 1;
|
||||
let cardinalityStart = "1";
|
||||
@ -25,8 +25,8 @@ export default function Relationship({ data }) {
|
||||
|
||||
switch (data.cardinality) {
|
||||
// the translated values are to ensure backwards compatibility
|
||||
case t(Cardinality.MANY_TO_ONE):
|
||||
case Cardinality.MANY_TO_ONE:
|
||||
case t(Cardinality.ZERO_TO_MANY):
|
||||
case Cardinality.ZERO_TO_MANY:
|
||||
if (settings.notation === 'default') {
|
||||
cardinalityStart = "n";
|
||||
cardinalityEnd = "1";
|
||||
@ -145,6 +145,7 @@ export default function Relationship({ data }) {
|
||||
{CrowZM(pathRef.current,settings.notation, cardinalityvar, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, direction, cardinalityStart, cardinalityEnd)}
|
||||
{DefaultNotation(pathRef.current,settings.notation, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, cardinalityStart, cardinalityEnd)}
|
||||
{IDEFZM(pathRef.current,settings.notation, cardinalityvar, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, direction, cardinalityStart, cardinalityEnd)}
|
||||
{sub01(pathRef.current,settings.notation, cardinalityvar, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, direction, cardinalityStart, cardinalityEnd)}
|
||||
</g>
|
||||
|
||||
<SideSheet
|
||||
|
@ -145,7 +145,7 @@ export function CrowZM(pathRef, notation, cardinalityvar, cardinalityEndX, cardi
|
||||
pathRef && notation === 'crows_foot' && (cardinalityvar==1) &&(
|
||||
<>
|
||||
<circle
|
||||
cx={cardinalityEndX-24}
|
||||
cx={cardinalityEndX-(24*direction)}
|
||||
cy={cardinalityEndY}
|
||||
r="4"
|
||||
stroke="gray"
|
||||
@ -294,3 +294,98 @@ export function IDEFZM(pathRef, notation, cardinalityvar, cardinalityEndX, cardi
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export function sub01(pathRef, notation, cardinalityvar, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, direction, cardinalityStart, cardinalityEnd){
|
||||
return(
|
||||
pathRef && notation === 'idef1x' && (cardinalityvar==2) &&(
|
||||
<>
|
||||
<circle
|
||||
cx={cardinalityEndX-(((cardinalityEndX-cardinalityStartX)/3)*direction)}
|
||||
cy={cardinalityEndY}
|
||||
r="8"
|
||||
stroke="gray"
|
||||
strokeWidth='2'
|
||||
fill="white"
|
||||
className="group-hover:fill-sky-700"
|
||||
/>
|
||||
<line
|
||||
x1={cardinalityEndX-(((cardinalityEndX-cardinalityStartX+24)/3)*direction)}
|
||||
y1={cardinalityEndY+20}
|
||||
x2={cardinalityEndX-(((cardinalityEndX-cardinalityStartX+24)/3)*direction)}
|
||||
y2={cardinalityEndY-20}
|
||||
stroke="gray"
|
||||
strokeWidth='2'
|
||||
className="group-hover:fill-sky-700"
|
||||
/>
|
||||
<text
|
||||
x={cardinalityStartX}
|
||||
y={cardinalityStartY-10}
|
||||
fill="black"
|
||||
strokeWidth="0.5"
|
||||
textAnchor="middle"
|
||||
alignmentBaseline="middle"
|
||||
>
|
||||
{cardinalityStart}
|
||||
</text>
|
||||
<text
|
||||
x={cardinalityEndX-15}
|
||||
y={cardinalityEndY-15}
|
||||
fill="black"
|
||||
strokeWidth="0.5"
|
||||
textAnchor="middle"
|
||||
alignmentBaseline="middle"
|
||||
>
|
||||
{cardinalityEnd}
|
||||
</text>
|
||||
</>
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export function sub011(pathRef, notation, cardinalityvar, cardinalityEndX, cardinalityEndY, cardinalityStartX, cardinalityStartY, direction, cardinalityStart, cardinalityEnd){
|
||||
return(
|
||||
pathRef && notation === 'idef1x' && (cardinalityvar==3) &&(
|
||||
<>
|
||||
<circle
|
||||
cx={cardinalityEndX-(((cardinalityEndX-cardinalityStartX)/3)*direction)}
|
||||
cy={cardinalityEndY}
|
||||
r="8"
|
||||
stroke="gray"
|
||||
strokeWidth='2'
|
||||
fill="white"
|
||||
className="group-hover:fill-sky-700"
|
||||
/>
|
||||
<line
|
||||
x1={cardinalityEndX-(((cardinalityEndX-cardinalityStartX+24)/3)*direction)}
|
||||
y1={cardinalityEndY+20}
|
||||
x2={cardinalityEndX-(((cardinalityEndX-cardinalityStartX+24)/3)*direction)}
|
||||
y2={cardinalityEndY-20}
|
||||
stroke="gray"
|
||||
strokeWidth='2'
|
||||
className="group-hover:fill-sky-700"
|
||||
/>
|
||||
<text
|
||||
x={cardinalityStartX}
|
||||
y={cardinalityStartY-10}
|
||||
fill="black"
|
||||
strokeWidth="0.5"
|
||||
textAnchor="middle"
|
||||
alignmentBaseline="middle"
|
||||
>
|
||||
{cardinalityStart}
|
||||
</text>
|
||||
<text
|
||||
x={cardinalityEndX-15}
|
||||
y={cardinalityEndY-15}
|
||||
fill="black"
|
||||
strokeWidth="0.5"
|
||||
textAnchor="middle"
|
||||
alignmentBaseline="middle"
|
||||
>
|
||||
{cardinalityEnd}
|
||||
</text>
|
||||
</>
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ function Relationship({ relationship, tables }) {
|
||||
let cardinalityEnd = "1";
|
||||
|
||||
switch (relationship.cardinality) {
|
||||
case Cardinality.MANY_TO_ONE:
|
||||
case Cardinality.ZERO_TO_MANY:
|
||||
cardinalityStart = "n";
|
||||
cardinalityEnd = "1";
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@ export const tableColorStripHeight = 7;
|
||||
export const Cardinality = {
|
||||
ONE_TO_ONE: "one_to_one",
|
||||
ONE_TO_MANY: "one_to_many",
|
||||
MANY_TO_ONE: "many_to_one",
|
||||
ZERO_TO_MANY: "zero_to_many",
|
||||
};
|
||||
|
||||
export const Constraint = {
|
||||
|
@ -140,7 +140,7 @@ const en = {
|
||||
swap: "Swap",
|
||||
one_to_one: "One to one",
|
||||
one_to_many: "One to many",
|
||||
many_to_one: "Many to one",
|
||||
zero_to_many: "Zero to many",
|
||||
content: "Content",
|
||||
types_info:
|
||||
"This feature is meant for object-relational DBMSs like PostgreSQL.\nIf used for MySQL or MariaDB a JSON type will be generated with the corresponding json validation check.\nIf used for SQLite it will be translated to a BLOB.\nIf used for MSSQL a type alias to the first field will be generated.",
|
||||
|
@ -289,7 +289,7 @@ export const template1 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "blog_posts_user_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 0,
|
||||
@ -300,7 +300,7 @@ export const template1 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "comments_blog_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 1,
|
||||
@ -311,7 +311,7 @@ export const template1 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "comments_user_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 2,
|
||||
@ -322,7 +322,7 @@ export const template1 = {
|
||||
endTableId: 3,
|
||||
endFieldId: 0,
|
||||
name: "blog_tag_tag_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 3,
|
||||
@ -333,7 +333,7 @@ export const template1 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "blog_tag_blog_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 4,
|
||||
|
@ -304,7 +304,7 @@ export const template2 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "employees_dep_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 0,
|
||||
@ -337,7 +337,7 @@ export const template2 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "project_assignment_employee_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 3,
|
||||
|
@ -376,7 +376,7 @@ export const template3 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "products_category_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero yo Many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 1,
|
||||
@ -387,7 +387,7 @@ export const template3 = {
|
||||
endTableId: 4,
|
||||
endFieldId: 0,
|
||||
name: "reviews_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero yo Many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 2,
|
||||
@ -409,7 +409,7 @@ export const template3 = {
|
||||
endTableId: 4,
|
||||
endFieldId: 0,
|
||||
name: "orders_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero yo Many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 4,
|
||||
|
@ -316,7 +316,7 @@ export const template4 = {
|
||||
endTableId: 2,
|
||||
endFieldId: 0,
|
||||
name: "books_author_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 0,
|
||||
@ -349,7 +349,7 @@ export const template4 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "books_genre_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 3,
|
||||
|
@ -554,7 +554,7 @@ export const template5 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "accounts_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 0,
|
||||
@ -565,7 +565,7 @@ export const template5 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "cards_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 1,
|
||||
@ -576,7 +576,7 @@ export const template5 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "loans_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 2,
|
||||
@ -587,7 +587,7 @@ export const template5 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "investments_customer_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 3,
|
||||
@ -598,7 +598,7 @@ export const template5 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "transactions_account_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 4,
|
||||
@ -609,7 +609,7 @@ export const template5 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "transfers_to_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 5,
|
||||
@ -620,7 +620,7 @@ export const template5 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "transfers_from_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 6,
|
||||
|
@ -400,7 +400,7 @@ export const template6 = {
|
||||
endTableId: 0,
|
||||
endFieldId: 0,
|
||||
name: "enrollment_student_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 0,
|
||||
@ -411,7 +411,7 @@ export const template6 = {
|
||||
endTableId: 1,
|
||||
endFieldId: 0,
|
||||
name: "enrollment_course_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 1,
|
||||
@ -444,7 +444,7 @@ export const template6 = {
|
||||
endTableId: 5,
|
||||
endFieldId: 0,
|
||||
name: "students_major_id_fk",
|
||||
cardinality: "Many to one",
|
||||
cardinality: "Zero to many",
|
||||
updateConstraint: "No action",
|
||||
deleteConstraint: "No action",
|
||||
id: 4,
|
||||
|
Loading…
Reference in New Issue
Block a user