@@ -46985,6 +46985,15 @@ var SchemaDesignerTable = class {
46985
46985
* The foreign keys of the table
46986
46986
*/
46987
46987
this.foreignKeys = [];
46988
+ /**
46989
+ * Opacity of the table
46990
+ * @default 1
46991
+ */
46992
+ this.opacity = 1;
46993
+ /**
46994
+ * Indicates if the table is visible
46995
+ */
46996
+ this.isVisible = true;
46988
46997
this.id = entity.id;
46989
46998
this.name = entity.name;
46990
46999
this.schema = entity.schema;
@@ -47114,6 +47123,7 @@ var SchemaDesignerTable = class {
47114
47123
parent.style.boxShadow = "0px 3px 8px rgba(0, 0, 0, 0.35), 0px 1px 3px rgba(0, 0, 0, 0.5), inset 0px 0.5px 0px rgba(255, 255, 255, 0.08), inset 0px 0px 0.5px rgba(255, 255, 255, 0.3)";
47115
47124
parent.style.display = "flex";
47116
47125
parent.style.flexDirection = "column";
47126
+ parent.style.opacity = this.opacity.toString();
47117
47127
parent.style.backgroundColor = "var(--sd-graph-background-color)";
47118
47128
const tableColor = src_default(this.schema, { format: "hex" });
47119
47129
const colorIndicator = document.createElement("div");
@@ -47321,6 +47331,9 @@ var SchemaDesignerLayout = class extends mxGraphFactory.mxGraphLayout {
47321
47331
const currentCell = dagCells[i];
47322
47332
if (!currentCell.edge) {
47323
47333
const value = currentCell.value;
47334
+ if (!value.isVisible) {
47335
+ continue;
47336
+ }
47324
47337
g.setNode(
47325
47338
currentCell.id,
47326
47339
{
@@ -47341,6 +47354,9 @@ var SchemaDesignerLayout = class extends mxGraphFactory.mxGraphLayout {
47341
47354
for (let i = 0; i < dagCells.length; i++) {
47342
47355
const currentCell = dagCells[i];
47343
47356
if (!currentCell.edge) {
47357
+ if (!currentCell.value.isVisible) {
47358
+ continue;
47359
+ }
47344
47360
const computedNode = g.node(currentCell.id);
47345
47361
currentCell.geometry.x = computedNode.x;
47346
47362
currentCell.geometry.y = computedNode.y;
@@ -48215,6 +48231,7 @@ var SchemaDesigner = class {
48215
48231
* Array of registered listeners for cell clicks
48216
48232
*/
48217
48233
this.cellClickListeners = [];
48234
+ this.filteredCellIds = [];
48218
48235
this.initializeGraph();
48219
48236
}
48220
48237
/**
@@ -48382,6 +48399,18 @@ var SchemaDesigner = class {
48382
48399
this.mxGraph.isCellFoldable = (_cell) => {
48383
48400
return false;
48384
48401
};
48402
+ const oldCellIsVisible = this.mxGraph.isCellVisible;
48403
+ this.mxGraph.isCellVisible = (cell2) => {
48404
+ const result2 = oldCellIsVisible.apply(this.mxGraph, [cell2]);
48405
+ if (cell2.vertex) {
48406
+ const cellValue = cell2.value;
48407
+ return result2 && cellValue.isVisible;
48408
+ } else if (cell2.edge) {
48409
+ const cellValue = cell2.value;
48410
+ return result2 && cellValue.isVisible;
48411
+ }
48412
+ return result2;
48413
+ };
48385
48414
this.mxGraph.convertValueToString = function(cell2) {
48386
48415
if (cell2?.value?.entity?.name !== void 0) {
48387
48416
return cell2.value.entity.name;
@@ -48486,7 +48515,8 @@ var SchemaDesigner = class {
48486
48515
referencedTableName: "",
48487
48516
referencedColumns: [],
48488
48517
onDeleteAction: "0" /* CASCADE */,
48489
- onUpdateAction: "0" /* CASCADE */
48518
+ onUpdateAction: "0" /* CASCADE */,
48519
+ isVisible: true
48490
48520
};
48491
48521
const edge = this.createEdge(foreignKey);
48492
48522
const style = this.graph.getCellStyle(edge);
@@ -48580,7 +48610,6 @@ var SchemaDesigner = class {
48580
48610
this._outlineContainer = document.createElement("div");
48581
48611
this._outlineContainer.classList.add("sd-outline");
48582
48612
this.container.appendChild(this._outlineContainer);
48583
- new mxGraphFactory.mxOutline(this.mxGraph, this._outlineContainer);
48584
48613
}
48585
48614
/**
48586
48615
* Initializes the toolbar for the schema designer
@@ -48675,6 +48704,25 @@ var SchemaDesigner = class {
48675
48704
this.config.publish(schema);
48676
48705
}
48677
48706
);
48707
+ this.toolbar.addButton(
48708
+ this.config.icons.editIcon,
48709
+ "filter",
48710
+ () => {
48711
+ const cells = this.mxModel.getChildCells(this.mxGraph.getDefaultParent());
48712
+ const filteredCells = cells.filter((cell2) => {
48713
+ if (cell2.vertex) {
48714
+ return Math.random() > 0.3;
48715
+ } else {
48716
+ return false;
48717
+ }
48718
+ }).map(
48719
+ (cell2) => {
48720
+ return cell2.value.id;
48721
+ }
48722
+ );
48723
+ this.filterCells(filteredCells);
48724
+ }
48725
+ );
48678
48726
}
48679
48727
if (this.config.showToolbar === false) {
48680
48728
toolbarBelt.style.display = "none";
@@ -48867,7 +48915,8 @@ var SchemaDesigner = class {
48867
48915
referencedTableName: targetValue.name,
48868
48916
referencedColumns: [foreignKey.referencedColumns[i]],
48869
48917
referencedSchemaName: targetValue.schema,
48870
- id: foreignKey.id
48918
+ id: foreignKey.id,
48919
+ isVisible: true
48871
48920
};
48872
48921
this.mxGraph.insertEdge(this.mxGraph.getDefaultParent(), null, edgeValue, source, target);
48873
48922
}
@@ -48990,7 +49039,9 @@ var SchemaDesigner = class {
48990
49039
name: "column_1",
48991
49040
dataType: "int",
48992
49041
isPrimaryKey: true,
48993
- isIdentity: true
49042
+ isIdentity: true,
49043
+ isNullable: false,
49044
+ isUnique: false
48994
49045
}
48995
49046
],
48996
49047
foreignKeys: []
@@ -49128,6 +49179,74 @@ var SchemaDesigner = class {
49128
49179
height
49129
49180
};
49130
49181
}
49182
+ filterCells(tableIds) {
49183
+ const cells = this.mxModel.getChildCells(this.mxGraph.getDefaultParent());
49184
+ if (tableIds === void 0 || tableIds.length === 0) {
49185
+ for (let i = 0; i < cells.length; i++) {
49186
+ const cell2 = cells[i];
49187
+ cell2.value.isVisible = true;
49188
+ cell2.value.opacity = 1;
49189
+ }
49190
+ return;
49191
+ }
49192
+ const visibleCells = [];
49193
+ let partiallyVisibleCells = [];
49194
+ const visibleEdges = [];
49195
+ let hiddenCells = [];
49196
+ for (let i = 0; i < cells.length; i++) {
49197
+ const cell2 = cells[i];
49198
+ if (cell2.vertex) {
49199
+ const tableValue = cell2.value;
49200
+ if (tableIds.includes(tableValue.id)) {
49201
+ visibleCells.push(cell2);
49202
+ } else {
49203
+ hiddenCells.push(cell2);
49204
+ }
49205
+ }
49206
+ if (cell2.edge) {
49207
+ if (cell2.source && cell2.target) {
49208
+ const sourceTableValue = cell2.source.value;
49209
+ const targetTableValue = cell2.target.value;
49210
+ if (tableIds.includes(sourceTableValue.id)) {
49211
+ visibleEdges.push(cell2);
49212
+ partiallyVisibleCells.push(cell2.target);
49213
+ }
49214
+ if (tableIds.includes(targetTableValue.id)) {
49215
+ visibleEdges.push(cell2);
49216
+ partiallyVisibleCells.push(cell2.source);
49217
+ }
49218
+ }
49219
+ }
49220
+ }
49221
+ hiddenCells = hiddenCells.filter((cell2) => {
49222
+ return !visibleCells.includes(cell2) && !partiallyVisibleCells.includes(cell2);
49223
+ });
49224
+ partiallyVisibleCells = partiallyVisibleCells.filter((cell2) => {
49225
+ return !visibleCells.includes(cell2);
49226
+ });
49227
+ for (let i = 0; i < visibleCells.length; i++) {
49228
+ const cell2 = visibleCells[i];
49229
+ cell2.value.isVisible = true;
49230
+ cell2.value.opacity = 1;
49231
+ }
49232
+ for (let i = 0; i < partiallyVisibleCells.length; i++) {
49233
+ const cell2 = partiallyVisibleCells[i];
49234
+ cell2.value.isVisible = true;
49235
+ cell2.value.opacity = 0.5;
49236
+ }
49237
+ for (let i = 0; i < hiddenCells.length; i++) {
49238
+ const cell2 = hiddenCells[i];
49239
+ cell2.value.isVisible = false;
49240
+ }
49241
+ for (let i = 0; i < visibleEdges.length; i++) {
49242
+ const cell2 = visibleEdges[i];
49243
+ cell2.value.isVisible = true;
49244
+ }
49245
+ this.autoLayout();
49246
+ this.mxGraph.refresh();
49247
+ this.mxOutline.destroy();
49248
+ this.configureMxOutline();
49249
+ }
49131
49250
};
49132
49251
var export_mx = import_mxgraph2.default;
49133
49252
export {
0 commit comments