Se añadió la función que solo se pueda formar una FK desde un atributo válido.

This commit is contained in:
Javier 2025-04-25 20:41:11 -06:00
parent 7e12237459
commit f3cf17820e
3 changed files with 8 additions and 3 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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",