Handle invalid references

This commit is contained in:
1ilit
2023-09-19 15:51:23 +03:00
parent 10fae6d518
commit 028e80a487
2 changed files with 25 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ import {
SelectContext,
} from "../pages/editor";
import Note from "./note";
import { Toast } from "@douyinfe/semi-ui";
export default function Canvas(props) {
const { tables, updateTable, relationships, addRelationship } =
@@ -325,6 +326,13 @@ export default function Canvas(props) {
const handleLinking = () => {
if (onRect.tableId < 0) return;
if (onRect.field < 0) return;
if (
tables[line.startTableId].fields[line.startFieldId].type !==
tables[onRect.tableId].fields[onRect.field].type
) {
Toast.info("Cannot connect");
return;
}
if (
line.startTableId === onRect.tableId &&
line.startFieldId === onRect.field
@@ -339,9 +347,7 @@ export default function Canvas(props) {
endY: tables[onRect.tableId].y + onRect.field * 36 + 69,
name: `${tables[line.startTableId].name}_FK_${
tables[line.startTableId].fields[line.startFieldId].name
}_to_${
tables[onRect.tableId].fields[onRect.field].name
}`,
}_to_${tables[onRect.tableId].fields[onRect.field].name}`,
id: relationships.length,
});
};