From aa4fb690136ae9e192801a59b41c3dd1c5cb8d09 Mon Sep 17 00:00:00 2001 From: ARCHITECT Date: Sat, 17 Jan 2026 22:57:04 +0000 Subject: [PATCH] Add storage category and separate relation type filters - Add 'storage' category with orange color (#FF6F00) - Split single relations checkbox into 3 separate checkboxes: - FK (Foreign Key) - blue - Ref (Reference) - orange - Logical - gray dashed - Each relation type can be toggled independently Co-Authored-By: Claude Opus 4.5 --- src/views/TablesGraph.ts | 53 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/views/TablesGraph.ts b/src/views/TablesGraph.ts index e836cd2..baa2da6 100644 --- a/src/views/TablesGraph.ts +++ b/src/views/TablesGraph.ts @@ -34,7 +34,7 @@ export class TablesGraph { private svg: D3Selection | null = null; private g: D3Selection | null = null; private showCategories: Set; - private showRelations = true; + private showRelationTypes: Set = new Set(['fk', 'ref', 'logical']); private nodeSize = 35; private linkDist = 100; @@ -95,16 +95,14 @@ export class TablesGraph { id: t.name })); - // Build edges (only between visible tables, if relations are enabled) - const edges: TableEdge[] = this.showRelations - ? this.schema.relations - .filter(r => tableNames.has(r.from) && tableNames.has(r.to)) - .map(r => ({ - source: r.from, - target: r.to, - type: r.type - })) - : []; + // Build edges (only between visible tables and enabled relation types) + const edges: TableEdge[] = this.schema.relations + .filter(r => tableNames.has(r.from) && tableNames.has(r.to) && this.showRelationTypes.has(r.type)) + .map(r => ({ + source: r.from, + target: r.to, + type: r.type + })); if (nodes.length === 0) { this.container.innerHTML = '
Sin tablas para mostrar
'; @@ -292,21 +290,20 @@ export class TablesGraph {
Relaciones
-
+ FK (Foreign Key) -
-
+ +
-
+ +
+
@@ -345,14 +342,18 @@ export class TablesGraph { }; }); - // Toggle relations - const toggleRelations = sidebar.querySelector('#toggle-relations'); - if (toggleRelations) { - toggleRelations.onchange = () => { - this.showRelations = toggleRelations.checked; + // Relation type checkboxes + sidebar.querySelectorAll('[data-rel]').forEach(cb => { + cb.onchange = () => { + const relType = cb.dataset.rel as TableRelation['type']; + if (cb.checked) { + this.showRelationTypes.add(relType); + } else { + this.showRelationTypes.delete(relType); + } this.render(); }; - } + }); // Node size const nodeSize = sidebar.querySelector('#graph-node-size');