Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: "many" relation arrow (#4161)

Liu Ji2209c5e5ebd9
diff --git a/frontend/src/components/SchemaDiagram/ER/ForeignKeyLine.vue b/frontend/src/components/SchemaDiagram/ER/ForeignKeyLine.vue
index 771484aae9..8e7341eeeb 100644
--- a/frontend/src/components/SchemaDiagram/ER/ForeignKeyLine.vue
+++ b/frontend/src/components/SchemaDiagram/ER/ForeignKeyLine.vue
@@ -1,7 +1,7 @@
<template>
<SVGLine
:path="path"
- :decorators="[]"
+ :decorators="[startManyArrow]"
:bb-edge-from="`${fk.from.table.name}.${fk.from.column}`"
:bb-edge-to="`${fk.to.table.name}.${fk.to.column}`"
:bb-fk-name="fk.metadata.name"
@@ -119,6 +119,26 @@ const generateLine = (src: Rect, se: Direction, dest: Rect, de: Direction) => {
const dc = grow(dp, de, GROWTH_LEN); // destination corner
return [sp, sc, dc, dp];
};
+const startManyArrow = computed((): Path => {
+ if (path.value.length < 2) return [];
+ /**
+ * Create a "fork"-like line to indicate "to-many" relationship
+ * m
+ * /
+ * q--c--p
+ * \
+ * n
+ */
+ const p = path.value[0];
+ const q = path.value[1];
+ const dir = Math.sign(q.x - p.x);
+ const h = 12;
+ const v = 6;
+ const m = { x: p.x, y: p.y + v };
+ const c = { x: p.x + h * dir, y: p.y };
+ const n = { x: p.x, y: p.y - v };
+ return [m, c, n];
+});
const updatePath = () => {
const { from, to } = props.fk;
diff --git a/frontend/src/components/SchemaDiagram/ER/libs/SVGLine.vue b/frontend/src/components/SchemaDiagram/ER/libs/SVGLine.vue
index 5351764bd5..bace0c204a 100644
--- a/frontend/src/components/SchemaDiagram/ER/libs/SVGLine.vue
+++ b/frontend/src/components/SchemaDiagram/ER/libs/SVGLine.vue
@@ -10,6 +10,7 @@
top: `${bbox.y + viewBox.y}px`,
width: `${viewBox.width}px`,
height: `${viewBox.height}px`,
+ 'z-index': hover ? 1 : 0,
}"
>
<path
@@ -31,7 +32,7 @@
fill="none"
:stroke="hover ? COLORS.LINE.HOVER : COLORS.LINE.NORMAL"
stroke-width="1"
- pointer-events="visibleStroke"
+ pointer-events="none"
/>
<path
ref="line"