diff --git a/frontend/packages/erd-core/src/components/ERDRenderer/ERDContent/TableNode/TableColumnList/TableColumn/TableColumn.tsx b/frontend/packages/erd-core/src/components/ERDRenderer/ERDContent/TableNode/TableColumnList/TableColumn/TableColumn.tsx index bf7ad46e..c1d26f38 100644 --- a/frontend/packages/erd-core/src/components/ERDRenderer/ERDContent/TableNode/TableColumnList/TableColumn/TableColumn.tsx +++ b/frontend/packages/erd-core/src/components/ERDRenderer/ERDContent/TableNode/TableColumnList/TableColumn/TableColumn.tsx @@ -1,3 +1,4 @@ +import { useHiddenNodesStore } from '@/stores/hiddenNodes' import type { Column, Relationships, Table } from '@liam-hq/db-structure' import { DiamondFillIcon, DiamondIcon, KeyRound } from '@liam-hq/ui' import { Handle, Position } from '@xyflow/react' @@ -25,14 +26,19 @@ export const TableColumn: FC = ({ }) => { const handleId = `${table.name}-${column.name}` - const isSource = Object.values(relationships).some( + const hiddenNodes = useHiddenNodesStore() + + const isVisibleSourceCardinality = Object.values(relationships).some( (relationship) => relationship.primaryTableName === table.name && - relationship.primaryColumnName === column.name, + relationship.primaryColumnName === column.name && + !hiddenNodes.includes(relationship.foreignTableName), ) const targetCardinality = Object.values(relationships).find( - ({ foreignTableName, foreignColumnName }) => - foreignTableName === table.name && foreignColumnName === column.name, + ({ foreignTableName, foreignColumnName, primaryTableName }) => + foreignTableName === table.name && + foreignColumnName === column.name && + !hiddenNodes.includes(primaryTableName), )?.cardinality return ( @@ -70,7 +76,7 @@ export const TableColumn: FC = ({ {column.type} - {isSource && ( + {isVisibleSourceCardinality && ( <> = ({ tableName, hidden }) => { const handleClick = useCallback( (event: MouseEvent) => { event.stopPropagation() + !hidden ? addHiddenNode(tableName) : removeHiddenNode(tableName) updateNode(tableName, (node) => ({ ...node, hidden: !node.hidden })) }, - [updateNode, tableName], + [updateNode, tableName, hidden], ) return (