Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0f47cbb
crowfoot
Patricio2002 Nov 26, 2024
72e5d76
Agregar botón para cambiar de notación
Francisco-Galindo Dec 3, 2024
6b6c5bc
Using cached settings
Francisco-Galindo Dec 3, 2024
d41876e
Agrego localización para inglés y español de selección de notaciones
Francisco-Galindo Dec 3, 2024
a0f5fc2
IDEF1x
Patricio2002 Dec 17, 2024
392cd0a
Agregar opción para cambiar a notación idef1x
Francisco-Galindo Dec 17, 2024
413dfa0
Agregar locale para menú de elección de IDEF1X
Francisco-Galindo Dec 17, 2024
cc08f45
Refactor: selection of path to draw for relationships
Francisco-Galindo Jan 14, 2025
1e6aeca
Add documentation links (#343)
1ilit Feb 14, 2025
799a79e
Add translations for Uyghurs language (#345)
swan019 Feb 25, 2025
e3877ef
Add romanian locale (#348)
44David Feb 26, 2025
0d813fc
Import from and export to DBML (#351)
1ilit Mar 1, 2025
0e54dbe
Remove funding (#352)
1ilit Mar 3, 2025
8fe4ec5
Update README.md
1ilit Mar 3, 2025
885eb82
Deprecate ddb export(#353)
1ilit Mar 4, 2025
8f9c447
Add table styling for crows_foot and idef1x
Francisco-Galindo Mar 5, 2025
e1ca9b0
Add missing entries to the Hungarian translations (#354)
picimako Mar 5, 2025
50e7201
slight modifications to the table view
HansMarcus01 Mar 6, 2025
6cc9942
Fix hotkeys (#357)
1ilit Mar 7, 2025
0c3b428
fixing bug of the constraint null and not null
HansMarcus01 Mar 11, 2025
a6f3f5f
Adding a dynamic box for rowsof type primary key
HansMarcus01 Mar 11, 2025
fa1e736
Add speed insights (#359)
1ilit Mar 11, 2025
a3886e7
Merge branch 'main' into notation
Francisco-Galindo Mar 12, 2025
f268f69
Make cardinalities look decent on all notations
Francisco-Galindo Mar 12, 2025
f5fe8a1
Adding formatting and removing unused code
HansMarcus01 Apr 7, 2025
cc89a92
Añadiendo boton para cambiar el tipo de ralación y agregado la notaci…
HansMarcus01 Apr 7, 2025
5ff1d07
deleted unused code
HansMarcus01 Apr 26, 2025
7e5cfb7
When creating a table with no attributes except the PK, the table bor…
HansMarcus01 May 15, 2025
8e0075a
Merge commit of the branch dependency-levels
HansMarcus01 Jun 10, 2025
c6516a7
Dependency levels have been added to the modeler.
HansMarcus01 Jun 14, 2025
536ed96
Fixing linting errors
HansMarcus01 Jun 14, 2025
a36430f
breakpoints
Patricio2002 Jun 17, 2025
9733ad6
FIX error
Patricio2002 Jun 17, 2025
b7b6cd7
In this commit, support for one-to-one and one-to-many relationship t…
HansMarcus01 Jun 19, 2025
7ab6375
Merge branch 'lines' into feat-relationship-representation
Patricio2002 Jun 27, 2025
b13ca65
Merge pull request #24 from LIDSOL/feat-relationship-representation
Patricio2002 Jun 27, 2025
8ea72eb
FIX Relationship.jsx
Patricio2002 Jun 27, 2025
717f8c0
Revert "Merge branch 'lines' into feat-relationship-representation"
Patricio2002 Jun 27, 2025
1e5573e
package
Patricio2002 Jun 27, 2025
80a7eb2
Merge branch 'feat-relationship-representation' into lines
Patricio2002 Jun 27, 2025
aabc237
FIX: line movements
Patricio2002 Jun 28, 2025
c08c8ed
menu for subtypes
Patricio2002 Jun 28, 2025
0668828
añadido menu subtipo y diseños
Patricio2002 Jun 30, 2025
16d3df0
FIX simplecanvas
Patricio2002 Jun 30, 2025
5b5c182
remove numbers from subs
Patricio2002 Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<a href="https://x.com/drawDB_" style="display: flex; align-items: center;">
<img src="https://img.shields.io/badge/Follow%20us%20on%20X-blue?logo=X" alt="Follow us on X"/>
</a>
<a href="https://buymeacoffee.com/drawdb" style="display: flex; align-items: center;">
<img src="https://img.shields.io/badge/Support%20us-grey?logo=buymeacoffee" alt="Support us"/>
</a>
</div>

<h3 align="center"><img width="700" style="border-radius:5px;" alt="demo" src="drawdb.png"></h3>
Expand Down
85 changes: 85 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"dependencies": {
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-sql": "^6.6.3",
"@dbml/core": "^3.9.7-alpha.0",
"@douyinfe/semi-ui": "^2.51.3",
"@lexical/react": "^0.12.5",
"@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",
"@vercel/speed-insights": "^1.2.0",
"axios": "^1.7.4",
"classnames": "^2.5.1",
"dexie": "^3.2.4",
Expand Down
1 change: 0 additions & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
User-agent: *
Allow: /
Allow: /editor
Allow: /shortcuts
Allow: /templates
Disallow: /bug-report
Disallow: /survey
9 changes: 0 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useLayoutEffect } from "react";
import Editor from "./pages/Editor";
import Survey from "./pages/Survey";
import BugReport from "./pages/BugReport";
import Shortcuts from "./pages/Shortcuts";
import Templates from "./pages/Templates";
import LandingPage from "./pages/LandingPage";
import SettingsContextProvider from "./context/SettingsContext";
Expand Down Expand Up @@ -33,14 +32,6 @@ export default function App() {
</ThemedPage>
}
/>
<Route
path="/shortcuts"
element={
<ThemedPage>
<Shortcuts />
</ThemedPage>
}
/>
<Route
path="/bug-report"
element={
Expand Down
71 changes: 48 additions & 23 deletions src/components/EditorCanvas/Canvas.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useRef, useState } from "react";
import {
Action,
Cardinality,
RelationshipType,
RelationshipCardinalities,
Constraint,
darkBgTheme,
ObjectType,
Expand Down Expand Up @@ -635,7 +636,7 @@ export default function Canvas() {
});
};

const handleGripField = (field) => {
const handleGripField = (field, fieldTableid) => {
// A field can be a foreign key only if it's a primary key or both NOT NULL and UNIQUE.
// If it can't be selected, show an error message and exit.
if (!field.primary && !(field.notNull && field.unique)) {
Expand All @@ -646,10 +647,14 @@ export default function Canvas() {
setDragging({ element: ObjectType.NONE, id: -1, prevX: 0, prevY: 0 });
setLinkingLine({
...linkingLine,
startTableId: field.tableId,
startTableId: fieldTableid,
startFieldId: field.id,
startX: pointer.spaces.diagram.x,
startY: pointer.spaces.diagram.y,
endX: pointer.spaces.diagram.x,
endY: pointer.spaces.diagram.y,
endTableId: -1,
endFieldId: -1,
});
setLinking(true);
};
Expand All @@ -659,31 +664,52 @@ export default function Canvas() {
// Get the childTable and parentTable
const childTable = tables.find((t) => t.id === hoveredTable.tableId);
const parentTable = tables.find((t) => t.id === linkingLine.startTableId);

if (!parentTable) {
console.error("Parent table not found for linking.");
setLinking(false);
return;
}
if (!childTable) {
console.error("Child table not found for linking.");
setLinking(false);
return;
}
const parentFields = parentTable.fields.filter((field) => field.primary);

if (parentFields.length === 0) {
Toast.info(t("no_primary_key"));
setLinking(false);
return;
}
// If the relationship is recursive
const recursiveRelation = parentTable === childTable;
if (!recursiveRelation) {
if (!areFieldsCompatible(parentFields, childTable)) {
Toast.info(t("duplicate_field_name"));
setLinking(false);
return;
}
}
// Check if the relationship already exists
const alreadyLinked = relationships.some(
(rel) =>
rel.startTableId === linkingLine.startTableId &&
rel.endTableId === hoveredTable.tableId
rel.endTableId === hoveredTable.tableId &&
rel.startFieldId === linkingLine.startFieldId &&
rel.endFieldId === (parentFields.map(
(field, index) =>
childTable.fields.reduce(
(maxId, f) =>
Math.max(maxId, typeof f.id === 'number' ? f.id : -1), -1) + 1 + index)[0])
);
if (alreadyLinked) {
Toast.info(t("duplicate_relationship"));
setLinking(false);
return;
}

// Save the ID of the child table before modifying its fields
const childTableIdForFks = childTable.id;
// Generate new fields for the childTable
const newFields = parentFields.map((field, index) => ({
name: recursiveRelation ? "" : field.name,
Expand All @@ -701,39 +727,38 @@ export default function Canvas() {
tableId: parentTable.id,
fieldId: field.id,
},
id: childTable.fields.length + index, // Ensure IDs are unique
id: childTable.fields.reduce((maxId, f) => Math.max(maxId, typeof f.id === 'number' ? f.id : -1), -1) + 1 + index,
}));

// Concatenate the existing fields with the new fields
const updatedChildFields = [...childTable.fields, ...newFields];

// Update the childTable with the new fields
updateTable(childTable.id, {
updateTable(childTableIdForFks, {
fields: updatedChildFields,
});

const actualStartFieldId = parentTable.fields.find(
(f) => f.id === linkingLine.startFieldId);
const relationshipName = `${parentTable.name}_${actualStartFieldId ? actualStartFieldId.name : 'table'}`;
// Use the updated childTable fields to create the new relationship
const newRelationship = {
...linkingLine,
endTableId: childTable.id,
// The new fields are added at the end of the childTable fields
endFieldId: updatedChildFields.length - 1,
startTableId: parentTable.id,
startFieldId: parentFields[0].id,
Cardinality: Cardinality.ONE_TO_ONE,
startTableId: linkingLine.startTableId,
startFieldId: linkingLine.startFieldId,
endTableId: hoveredTable.tableId,
endFieldId: newFields.length > 0 ? newFields[0].id : undefined,
relationshipType: RelationshipType.ONE_TO_ONE, // Default, can be changed by editing the relationship
cardinality: RelationshipCardinalities[RelationshipType.ONE_TO_ONE][0].label,
updateConstraint: Constraint.NONE,
deleteConstraint: Constraint.NONE,
name: `fk_${parentTable.name}_${parentFields[0].name}`,
id: relationships.length,
endField: newFields,
name: relationshipName,
subtype: false,
subtype_restriction: "",
};

delete newRelationship.startX;
delete newRelationship.startY;
delete newRelationship.endX;
delete newRelationship.endY;
// Add the new relationship to the relationships array
addRelationship(newRelationship);
addRelationship(newRelationship, newFields, childTableIdForFks, true);
setLinking(false);
};

Expand All @@ -743,7 +768,7 @@ export default function Canvas() {
(e) => {
e.preventDefault();

if (e.ctrlKey) {
if (e.ctrlKey || e.metaKey) {
// How "eager" the viewport is to
// center the cursor's coordinates
const eagernessFactor = 0.05;
Expand Down
Loading
Loading