From f3cf17820e1c571b47a6cad48aa6cc763e277e92 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 25 Apr 2025 20:41:11 -0600 Subject: [PATCH] =?UTF-8?q?Se=20a=C3=B1adi=C3=B3=20la=20funci=C3=B3n=20que?= =?UTF-8?q?=20solo=20se=20pueda=20formar=20una=20FK=20desde=20un=20atribut?= =?UTF-8?q?o=20v=C3=A1lido.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditorCanvas/Canvas.jsx | 6 +++++- src/components/EditorCanvas/Table.jsx | 4 ++-- src/i18n/locales/en.js | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/EditorCanvas/Canvas.jsx b/src/components/EditorCanvas/Canvas.jsx index 44ea706..50daf0d 100644 --- a/src/components/EditorCanvas/Canvas.jsx +++ b/src/components/EditorCanvas/Canvas.jsx @@ -400,7 +400,11 @@ export default function Canvas() { }); }; - const handleGripField = () => { + const handleGripField = (field) => { + if (!field.primary && !(field.notNull && field.unique)) { + Toast.info(t("cannot_fk")); + return; + } setPanning((old) => ({ ...old, isPanning: false })); setDragging({ element: ObjectType.NONE, id: -1, prevX: 0, prevY: 0 }); setLinking(true); diff --git a/src/components/EditorCanvas/Table.jsx b/src/components/EditorCanvas/Table.jsx index 1e656f9..19f235f 100644 --- a/src/components/EditorCanvas/Table.jsx +++ b/src/components/EditorCanvas/Table.jsx @@ -317,10 +317,10 @@ export default function Table(props) { onPointerDown={(e) => { if (!e.isPrimary) return; - handleGripField(index); + handleGripField(fieldData); setLinkingLine((prev) => ({ ...prev, - startFieldId: index, + startFieldId: fieldData.id, startTableId: tableData.id, startX: tableData.x + 15, startY: diff --git a/src/i18n/locales/en.js b/src/i18n/locales/en.js index 81c903a..0dad5a4 100644 --- a/src/i18n/locales/en.js +++ b/src/i18n/locales/en.js @@ -146,6 +146,7 @@ const en = { relationship_deleted: "Relationship deleted", type_deleted: "Type deleted", cannot_connect: "Cannot connect, the columns have different types", + cannot_fk: "Cannot create foreign key from this field", copied_to_clipboard: "Copied to clipboard", create_new_diagram: "Create new diagram", cancel: "Cancel",