Skip to content

Commit

Permalink
Fixing titles (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
aasimkhan30 authored Jan 23, 2025
1 parent b4da709 commit 5be21ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "azdataGraph",
"description": "azdataGraph is a derivative of mxGraph, which is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
"version": "0.0.75",
"version": "0.0.76",
"homepage": "https://github.com/microsoft/azdataGraph",
"author": "Microsoft",
"license": "Apache-2.0",
Expand Down
26 changes: 24 additions & 2 deletions src/ts/schemaDesigner/schemaDesignerEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class SchemaDesignerEntity implements IEntity {
header.appendChild(headerIcon);
const headerText = document.createElement("div");
headerText.classList.add("sd-table-header-text");
headerText.innerText = `${this.schema}.${this.name}`;
const tableTitle = `${this.schema}.${this.name}`;
headerText.innerText = tableTitle;
headerText.title = tableTitle;
header.appendChild(headerText);
parent.appendChild(header);

Expand All @@ -45,14 +47,15 @@ export class SchemaDesignerEntity implements IEntity {
if(this._config.icons.dataTypeIcons[column.dataType] !== undefined) {
columnIcon.innerHTML = this._config.icons.dataTypeIcons[column.dataType];
} else {
console.log(column.dataType);
columnIcon.innerHTML = this._config.icons.customDataTypeIcon;
}
columnIcon.title = column.dataType;
columnDiv.appendChild(columnIcon);
const columnText = document.createElement("div");
columnText.classList.add("sd-table-column-text");
columnText.title = column.name;
columnText.innerText = column.name;
columnText.title = this.getColumnTitle(column, index);
columnDiv.appendChild(columnText);
const columnConstraints = document.createElement("div");
columnConstraints.classList.add("sd-table-column-constraints");
Expand Down Expand Up @@ -85,4 +88,23 @@ export class SchemaDesignerEntity implements IEntity {
}
return constraints.join(", ");
}

private getColumnTitle(column: IColumn, index: number): string {
let columnTitle = `${column.name}`;
if (column.isPrimaryKey) {
columnTitle += ` Primary key`;
}
const cells = this._graph.getChildCells(this._graph.getDefaultParent());
const vertex = cells.find(cell => cell.vertex && cell.value.name === this.name && cell.value.schema === this.schema);
if (vertex) {
const edges = this._graph.getEdges(vertex);
const outgoingEdges = edges.filter(edge => edge.source === vertex);
for (const edge of outgoingEdges) {
if (edge.value.sourceRow - 1 === index) {
return columnTitle + ` Foreign key`;
}
}
}
return columnTitle;
}
}

0 comments on commit 5be21ba

Please sign in to comment.