mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-02 11:06:55 +00:00
chore(nc-gui): lint
This commit is contained in:
@@ -76,11 +76,11 @@ export function useErdElements(schema: MaybeRef<AiBaseSchema>, props: MaybeRef<A
|
||||
|
||||
const dagreGraph = new dagre.graphlib.Graph()
|
||||
dagreGraph.setDefaultEdgeLabel(() => ({}))
|
||||
dagreGraph.setGraph({
|
||||
dagreGraph.setGraph({
|
||||
rankdir: 'LR',
|
||||
align: 'UL',
|
||||
nodesep: 50,
|
||||
ranksep: 100
|
||||
ranksep: 100,
|
||||
})
|
||||
|
||||
const erdSchema = computed(() => unref(schema))
|
||||
@@ -232,14 +232,23 @@ export function useErdElements(schema: MaybeRef<AiBaseSchema>, props: MaybeRef<A
|
||||
dagre.layout(dagreGraph)
|
||||
|
||||
// Calculate bounds to center the layout
|
||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
|
||||
|
||||
let minX = Infinity
|
||||
let minY = Infinity
|
||||
let maxX = -Infinity
|
||||
let maxY = -Infinity
|
||||
|
||||
for (const el of elements.value) {
|
||||
if (isNode(el)) {
|
||||
const nodeWithPosition = dagreGraph.node(el.id)
|
||||
const width = skeleton ? nodeWidth * 3 : nodeWidth
|
||||
const height = nodeHeight.value + (skeleton ? 250 : (el as Node<AiNodeData>).data!.columnLength > 0 ? nodeHeight.value * (el as Node<AiNodeData>).data!.columnLength : nodeHeight.value)
|
||||
|
||||
const height =
|
||||
nodeHeight.value +
|
||||
(skeleton
|
||||
? 250
|
||||
: (el as Node<AiNodeData>).data!.columnLength > 0
|
||||
? nodeHeight.value * (el as Node<AiNodeData>).data!.columnLength
|
||||
: nodeHeight.value)
|
||||
|
||||
minX = Math.min(minX, nodeWithPosition.x - width / 2)
|
||||
minY = Math.min(minY, nodeWithPosition.y - height / 2)
|
||||
maxX = Math.max(maxX, nodeWithPosition.x + width / 2)
|
||||
@@ -260,9 +269,9 @@ export function useErdElements(schema: MaybeRef<AiBaseSchema>, props: MaybeRef<A
|
||||
el.targetPosition = Position.Left
|
||||
el.sourcePosition = Position.Right
|
||||
// Apply center offset to position nodes around the origin
|
||||
el.position = {
|
||||
x: nodeWithPosition.x + centerOffsetX,
|
||||
y: nodeWithPosition.y + centerOffsetY
|
||||
el.position = {
|
||||
x: nodeWithPosition.x + centerOffsetX,
|
||||
y: nodeWithPosition.y + centerOffsetY,
|
||||
}
|
||||
el.class = ['rounded-lg border-1 border-gray-200 shadow-lg'].join(' ')
|
||||
el.data.color = color
|
||||
|
||||
Reference in New Issue
Block a user