Browse Source

feat(nc-gui): set edge marker type for skeleton mode

pull/4071/head
braks 2 years ago
parent
commit
c3dee74074
  1. 3
      packages/nc-gui/components/erd/RelationEdge.vue
  2. 5
      packages/nc-gui/components/erd/utils.ts

3
packages/nc-gui/components/erd/RelationEdge.vue

@ -20,6 +20,7 @@ interface RelationEdgeProps extends EdgeProps {
style: CSSProperties style: CSSProperties
selected?: boolean selected?: boolean
showSkeleton: boolean showSkeleton: boolean
markerEnd: string
} }
const props = defineProps<RelationEdgeProps>() const props = defineProps<RelationEdgeProps>()
@ -70,6 +71,7 @@ export default {
:stroke-width="2" :stroke-width="2"
fill="none" fill="none"
:d="edgePath[0]" :d="edgePath[0]"
:marker-end="showSkeleton ? markerEnd : ''"
/> />
<path <path
class="opacity-0 hover:(opacity-100 transition-all duration-100 ease)" class="opacity-0 hover:(opacity-100 transition-all duration-100 ease)"
@ -78,6 +80,7 @@ export default {
:stroke-width="7" :stroke-width="7"
fill="none" fill="none"
:d="edgePath[0]" :d="edgePath[0]"
:marker-end="showSkeleton ? markerEnd : ''"
/> />
<EdgeText <EdgeText

5
packages/nc-gui/components/erd/utils.ts

@ -3,7 +3,7 @@ import { UITypes } from 'nocodb-sdk'
import dagre from 'dagre' import dagre from 'dagre'
import type { Edge, Elements } from '@vue-flow/core' import type { Edge, Elements } from '@vue-flow/core'
import type { MaybeRef } from '@vueuse/core' import type { MaybeRef } from '@vueuse/core'
import { Position, isEdge, isNode } from '@vue-flow/core' import { MarkerType, Position, isEdge, isNode } from '@vue-flow/core'
import { scaleLinear as d3ScaleLinear } from 'd3-scale' import { scaleLinear as d3ScaleLinear } from 'd3-scale'
import { computed, ref, unref, useMetas, useTheme } from '#imports' import { computed, ref, unref, useMetas, useTheme } from '#imports'
@ -160,6 +160,7 @@ export function useErdElements(tables: MaybeRef<TableType[]>, props: MaybeRef<Er
sourceHandle: `s-${sourceColumnId}-${source}`, sourceHandle: `s-${sourceColumnId}-${source}`,
targetHandle: `d-${targetColumnId}-${target}`, targetHandle: `d-${targetColumnId}-${target}`,
type: 'custom', type: 'custom',
markerEnd: MarkerType.ArrowClosed,
data: { data: {
isManyToMany: type === 'mm', isManyToMany: type === 'mm',
isSelfRelation: source === target && sourceColumnId === targetColumnId, isSelfRelation: source === target && sourceColumnId === targetColumnId,
@ -213,7 +214,7 @@ export function useErdElements(tables: MaybeRef<TableType[]>, props: MaybeRef<Er
if (isNode(el)) { if (isNode(el)) {
dagreGraph.setNode(el.id, { dagreGraph.setNode(el.id, {
width: skeleton ? nodeWidth * 2 : nodeWidth, width: skeleton ? nodeWidth * 2 : nodeWidth,
height: nodeHeight + (skeleton ? 100 : nodeHeight * el.data.columnLength), height: nodeHeight + (skeleton ? 250 : nodeHeight * el.data.columnLength),
}) })
} else if (isEdge(el)) { } else if (isEdge(el)) {
// avoid duplicate edges when using skeleton // avoid duplicate edges when using skeleton

Loading…
Cancel
Save