Skip to content

Commit

Permalink
Resolve #105 (#113)
Browse files Browse the repository at this point in the history
* Resolve #105

* Run linters

---------

Co-authored-by: Lint Bot <[email protected]>
  • Loading branch information
mewim and mewim authored Mar 19, 2024
1 parent 17bda36 commit a6f67ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/SchemaView/SchemaViewMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ export default {
getColor(label) {
return this.settingsStore.colorForLabel(label);
},
getRelTableDisplayLabel(relTableName) {
const relTable = this.schema.relTables.find(t => t.name === relTableName);
if (!relTable) {
return relTableName;
}
return relTable.group ? relTable.group : relTableName;
},
getLayoutConfig(edges) {
const nodeSpacing = edges.length * 5;
const config = {
Expand Down Expand Up @@ -380,7 +387,7 @@ export default {
this.g6graph.setItemState(edgeItem, 'hover', true);
if (this.settingsStore.schemaView.showRelLabels === SHOW_REL_LABELS_OPTIONS.HOVER) {
this.g6graph.updateItem(edgeItem, {
label: edgeItem._cfg.model._label
label: this.getRelTableDisplayLabel(edgeItem._cfg.model._label)
});
edgeItem.toFront();
}
Expand Down Expand Up @@ -411,7 +418,7 @@ export default {
this.g6graph.setItemState(edgeItem, 'click', true);
if (this.settingsStore.schemaView.showRelLabels === SHOW_REL_LABELS_OPTIONS.HOVER) {
this.g6graph.updateItem(edgeItem, {
label: edgeItem._cfg.model._label
label: this.getRelTableDisplayLabel(edgeItem._cfg.model._label)
});
edgeItem.toFront();
}
Expand Down Expand Up @@ -482,7 +489,7 @@ export default {
id: r.name,
source: r.src,
target: r.dst,
label: this.settingsStore.schemaView.showRelLabels === SHOW_REL_LABELS_OPTIONS.ALWAYS ? r.name : "",
label: this.settingsStore.schemaView.showRelLabels === SHOW_REL_LABELS_OPTIONS.ALWAYS ? this.getRelTableDisplayLabel(r.name) : "",
_label: r.name,
isPlaceholder: Boolean(r.isPlaceholder),
style: {
Expand Down Expand Up @@ -732,7 +739,7 @@ export default {
}
if (this.settingsStore.schemaView.showRelLabels === SHOW_REL_LABELS_OPTIONS.HOVER) {
this.g6graph.updateItem(g6Item, {
label: tableName
label: this.getRelTableDisplayLabel(tableName),
});
g6Item.toFront();
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/ShellView/ResultGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ export default {
};
}
const expectedPropertiesType = {};
const relTable = this.schema.relTables.find((table) => table.name === rawRel._label);
const expectedProperties = this.schema.relTables.find((table) => table.name === rawRel._label).properties;
expectedProperties.forEach((property) => {
expectedPropertiesType[property.name] = property.type;
Expand All @@ -609,6 +610,9 @@ export default {
g6Rel.label = "";
} else {
g6Rel.label = rawRel[relLabelProp];
if (relLabelProp === '_label' && relTable.group) {
g6Rel.label = relTable.group;
}
if (relLabelProp in expectedPropertiesType) {
g6Rel.label = ValueFormatter.beautifyValue(rawRel[relLabelProp], expectedPropertiesType[relLabelProp], relLabelProp);
}
Expand Down

0 comments on commit a6f67ed

Please sign in to comment.