Skip to content

Commit 3b6004b

Browse files
Release v0.0.121
1 parent 40b119e commit 3b6004b

14 files changed

+498
-73
lines changed

dist/index.js

+123-4
Original file line numberDiff line numberDiff line change
@@ -46985,6 +46985,15 @@ var SchemaDesignerTable = class {
4698546985
* The foreign keys of the table
4698646986
*/
4698746987
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;
4698846997
this.id = entity.id;
4698946998
this.name = entity.name;
4699046999
this.schema = entity.schema;
@@ -47114,6 +47123,7 @@ var SchemaDesignerTable = class {
4711447123
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)";
4711547124
parent.style.display = "flex";
4711647125
parent.style.flexDirection = "column";
47126+
parent.style.opacity = this.opacity.toString();
4711747127
parent.style.backgroundColor = "var(--sd-graph-background-color)";
4711847128
const tableColor = src_default(this.schema, { format: "hex" });
4711947129
const colorIndicator = document.createElement("div");
@@ -47321,6 +47331,9 @@ var SchemaDesignerLayout = class extends mxGraphFactory.mxGraphLayout {
4732147331
const currentCell = dagCells[i];
4732247332
if (!currentCell.edge) {
4732347333
const value = currentCell.value;
47334+
if (!value.isVisible) {
47335+
continue;
47336+
}
4732447337
g.setNode(
4732547338
currentCell.id,
4732647339
{
@@ -47341,6 +47354,9 @@ var SchemaDesignerLayout = class extends mxGraphFactory.mxGraphLayout {
4734147354
for (let i = 0; i < dagCells.length; i++) {
4734247355
const currentCell = dagCells[i];
4734347356
if (!currentCell.edge) {
47357+
if (!currentCell.value.isVisible) {
47358+
continue;
47359+
}
4734447360
const computedNode = g.node(currentCell.id);
4734547361
currentCell.geometry.x = computedNode.x;
4734647362
currentCell.geometry.y = computedNode.y;
@@ -48215,6 +48231,7 @@ var SchemaDesigner = class {
4821548231
* Array of registered listeners for cell clicks
4821648232
*/
4821748233
this.cellClickListeners = [];
48234+
this.filteredCellIds = [];
4821848235
this.initializeGraph();
4821948236
}
4822048237
/**
@@ -48382,6 +48399,18 @@ var SchemaDesigner = class {
4838248399
this.mxGraph.isCellFoldable = (_cell) => {
4838348400
return false;
4838448401
};
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+
};
4838548414
this.mxGraph.convertValueToString = function(cell2) {
4838648415
if (cell2?.value?.entity?.name !== void 0) {
4838748416
return cell2.value.entity.name;
@@ -48486,7 +48515,8 @@ var SchemaDesigner = class {
4848648515
referencedTableName: "",
4848748516
referencedColumns: [],
4848848517
onDeleteAction: "0" /* CASCADE */,
48489-
onUpdateAction: "0" /* CASCADE */
48518+
onUpdateAction: "0" /* CASCADE */,
48519+
isVisible: true
4849048520
};
4849148521
const edge = this.createEdge(foreignKey);
4849248522
const style = this.graph.getCellStyle(edge);
@@ -48580,7 +48610,6 @@ var SchemaDesigner = class {
4858048610
this._outlineContainer = document.createElement("div");
4858148611
this._outlineContainer.classList.add("sd-outline");
4858248612
this.container.appendChild(this._outlineContainer);
48583-
new mxGraphFactory.mxOutline(this.mxGraph, this._outlineContainer);
4858448613
}
4858548614
/**
4858648615
* Initializes the toolbar for the schema designer
@@ -48675,6 +48704,25 @@ var SchemaDesigner = class {
4867548704
this.config.publish(schema);
4867648705
}
4867748706
);
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+
);
4867848726
}
4867948727
if (this.config.showToolbar === false) {
4868048728
toolbarBelt.style.display = "none";
@@ -48867,7 +48915,8 @@ var SchemaDesigner = class {
4886748915
referencedTableName: targetValue.name,
4886848916
referencedColumns: [foreignKey.referencedColumns[i]],
4886948917
referencedSchemaName: targetValue.schema,
48870-
id: foreignKey.id
48918+
id: foreignKey.id,
48919+
isVisible: true
4887148920
};
4887248921
this.mxGraph.insertEdge(this.mxGraph.getDefaultParent(), null, edgeValue, source, target);
4887348922
}
@@ -48990,7 +49039,9 @@ var SchemaDesigner = class {
4899049039
name: "column_1",
4899149040
dataType: "int",
4899249041
isPrimaryKey: true,
48993-
isIdentity: true
49042+
isIdentity: true,
49043+
isNullable: false,
49044+
isUnique: false
4899449045
}
4899549046
],
4899649047
foreignKeys: []
@@ -49128,6 +49179,74 @@ var SchemaDesigner = class {
4912849179
height
4912949180
};
4913049181
}
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+
}
4913149250
};
4913249251
var export_mx = import_mxgraph2.default;
4913349252
export {

dist/index.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/ts/schemaDesigner/schemaDesigner.d.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './schemaDesigner.css';
22
import '../../css/common.css';
3-
import { IForeignKey, ISchema, ITable, SchemaDesignerColors, SchemaDesignerConfig } from './schemaDesignerInterfaces';
4-
import { mxCell, mxCellState, mxEditor, mxGraph, mxGraphLayout, mxGraphModel } from 'mxgraph';
3+
import { ForeignKey, Schema, SchemaDesignerColors, SchemaDesignerConfig, Table } from './schemaDesignerInterfaces';
4+
import { mxCell, mxCellState, mxEditor, mxGraph, mxGraphLayout, mxGraphModel, mxOutline } from 'mxgraph';
55
import { SchemaDesignerToolbar } from './schemaDesignerToolbar';
66
export declare class SchemaDesigner {
77
private container;
@@ -22,6 +22,10 @@ export declare class SchemaDesigner {
2222
* mxGraph instance for the schema designer
2323
*/
2424
mxGraph: mxGraph;
25+
/**
26+
* mxGraph instance for the schema designer
27+
*/
28+
mxOutline: mxOutline;
2529
/**
2630
* mxModel instance for the schema designer
2731
*/
@@ -35,6 +39,7 @@ export declare class SchemaDesigner {
3539
*/
3640
toolbar: SchemaDesignerToolbar;
3741
private _outlineContainer;
42+
filteredCellIds: string[];
3843
constructor(container: HTMLElement, config: SchemaDesignerConfig);
3944
/**
4045
* Sets up the mxGraph instance for the schema designer
@@ -99,25 +104,25 @@ export declare class SchemaDesigner {
99104
* @param schema The schema to render
100105
* @param cleanUndoManager Whether to clean the undo manager so that the user can't undo the rendering
101106
*/
102-
renderSchema(schema: ISchema, cleanUndoManager?: boolean): void;
107+
renderSchema(schema: Schema, cleanUndoManager?: boolean): void;
103108
/**
104109
* Renders an entity in the schema designer
105110
* @param entity The entity to render
106111
* @param x the x position to render the entity at
107112
* @param y the y position to render the entity at
108113
* @returns The cell that was rendered
109114
*/
110-
renderTable(entity: ITable, x: number, y: number): mxCell;
115+
renderTable(entity: Table, x: number, y: number): mxCell;
111116
/**
112117
* Renders a relationship in the schema designer
113118
* @param relationship The relationship to render
114119
* @returns The edge that was rendered
115120
*/
116-
renderForeignKey(foreignKey: IForeignKey, sourceTable: ITable): void;
121+
renderForeignKey(foreignKey: ForeignKey, sourceTable: Table): void;
117122
/**
118123
* Gets the current schema from the schema designer
119124
*/
120-
get schema(): ISchema;
125+
get schema(): Schema;
121126
/**
122127
* Automatically arranges the cells in the schema designer
123128
*/
@@ -158,13 +163,14 @@ export declare class SchemaDesigner {
158163
* @param editedOutgoingEdges describes the new relationships
159164
* @returns void
160165
*/
161-
updateActiveCellStateTable(editedTable: ITable): void;
162-
getForeignKeysForTable(tableCell: mxCell): IForeignKey[];
166+
updateActiveCellStateTable(editedTable: Table): void;
167+
getForeignKeysForTable(tableCell: mxCell): ForeignKey[];
163168
makeElementDraggable(element: HTMLElement, onDragEndCallback?: (graph: mxGraph, evt: MouseEvent, cell: mxCellState) => void): void;
164169
exportImage(format: string): Promise<{
165170
fileContent: string;
166171
format: string;
167172
width: number;
168173
height: number;
169174
}>;
175+
filterCells(tableIds?: string[]): void;
170176
}

0 commit comments

Comments
 (0)