mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
perspective: view fix, UX
This commit is contained in:
parent
c1627b8546
commit
e64d013fee
@ -106,10 +106,11 @@ export function createPerspectiveNodeConfig(name: { schemaName?: string; pureNam
|
||||
|
||||
expandedColumns: [],
|
||||
checkedColumns: [],
|
||||
// uncheckedColumns: [],
|
||||
|
||||
sort: [],
|
||||
filters: {},
|
||||
|
||||
isNodeChecked: true,
|
||||
};
|
||||
|
||||
return node;
|
||||
@ -117,7 +118,6 @@ export function createPerspectiveNodeConfig(name: { schemaName?: string; pureNam
|
||||
|
||||
export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig {
|
||||
const rootNode = createPerspectiveNodeConfig(rootObject);
|
||||
rootNode.isNodeChecked = true;
|
||||
return {
|
||||
nodes: [rootNode],
|
||||
references: [],
|
||||
|
@ -6,7 +6,7 @@ import { PerspectiveTableNode } from './PerspectiveTreeNode';
|
||||
function getPerspectiveDefaultColumns(
|
||||
table: TableInfo | ViewInfo,
|
||||
db: DatabaseInfo,
|
||||
circularColumns: string[]
|
||||
circularColumns?: string[]
|
||||
): [string[], string[]] {
|
||||
const columns = table.columns.map(x => x.columnName);
|
||||
const predicates = [
|
||||
@ -29,14 +29,16 @@ function getPerspectiveDefaultColumns(
|
||||
if (col) return [[col], null];
|
||||
}
|
||||
|
||||
const keyPredicates = [
|
||||
x => findForeignKeyForColumn(table as TableInfo, x)?.columns?.length == 1 && !circularColumns.includes(x),
|
||||
x => findForeignKeyForColumn(table as TableInfo, x)?.columns?.length == 1,
|
||||
];
|
||||
if (circularColumns) {
|
||||
const keyPredicates = [
|
||||
x => findForeignKeyForColumn(table as TableInfo, x)?.columns?.length == 1 && !circularColumns.includes(x),
|
||||
x => findForeignKeyForColumn(table as TableInfo, x)?.columns?.length == 1,
|
||||
];
|
||||
|
||||
for (const predicate of keyPredicates) {
|
||||
const col = columns.find(predicate);
|
||||
if (col) return [null, [col]];
|
||||
for (const predicate of keyPredicates) {
|
||||
const col = columns.find(predicate);
|
||||
if (col) return [null, [col]];
|
||||
}
|
||||
}
|
||||
|
||||
return [[columns[0]], null];
|
||||
@ -108,7 +110,24 @@ function processPerspectiveDefaultColunnsStep(
|
||||
|
||||
if (table || view) {
|
||||
const treeNode = root.findNodeByDesignerId(node.designerId);
|
||||
if (!treeNode) continue;
|
||||
|
||||
if (!treeNode) {
|
||||
const [defaultColumns] = getPerspectiveDefaultColumns(table || view, db, null);
|
||||
|
||||
return {
|
||||
...config,
|
||||
nodes: config.nodes.map(n =>
|
||||
n.designerId == node.designerId
|
||||
? {
|
||||
...n,
|
||||
defaultColumnsProcessed: true,
|
||||
checkedColumns: defaultColumns,
|
||||
}
|
||||
: n
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
const circularColumns = treeNode.childNodes.filter(x => x.isCircular).map(x => x.columnName);
|
||||
const [defaultColumns, defaultRefs] = getPerspectiveDefaultColumns(table || view, db, circularColumns);
|
||||
|
||||
|
@ -32,11 +32,14 @@
|
||||
const table = dbInfos?.[node.conid || conid]?.[node.database || database]?.tables?.find(
|
||||
x => x.pureName == node.pureName && x.schemaName == node.schemaName
|
||||
);
|
||||
if (!table) return null;
|
||||
const view = dbInfos?.[node.conid || conid]?.[node.database || database]?.views?.find(
|
||||
x => x.pureName == node.pureName && x.schemaName == node.schemaName
|
||||
);
|
||||
if (!table && !view) return null;
|
||||
|
||||
const { designerId } = node;
|
||||
return {
|
||||
...table,
|
||||
...(table || view),
|
||||
left: node?.position?.x || 0,
|
||||
top: node?.position?.y || 0,
|
||||
alias: node.alias,
|
||||
|
Loading…
Reference in New Issue
Block a user