fixed loading tables with maby FKs

This commit is contained in:
Jan Prochazka
2020-04-30 21:47:40 +02:00
parent c9a0dfcb53
commit 17134552ce
3 changed files with 15 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ export interface GridConfig extends GridConfigColumns {
export interface GridCache {
tables: { [uniqueName: string]: TableInfo };
loadingTables: { schemaName: string; pureName: string }[];
refreshTime: number;
}
@@ -35,6 +36,7 @@ export function createGridConfig(): GridConfig {
export function createGridCache(): GridCache {
return {
tables: {},
loadingTables: [],
refreshTime: new Date().getTime(),
};
}

View File

@@ -162,9 +162,20 @@ export class TableGridDisplay extends GridDisplay {
requireFkTarget(column: DisplayColumn) {
const { uniqueName, foreignKey } = column;
this.getTableInfo({ schemaName: foreignKey.refSchemaName, pureName: foreignKey.refTableName }).then((table) => {
const pureName = foreignKey.refTableName;
const schemaName = foreignKey.refSchemaName;
if (this.cache.loadingTables.find((x) => x.pureName == pureName && x.schemaName == schemaName)) return;
this.setCache((cache) => ({
...cache,
loadingTables: [...cache.loadingTables, { schemaName, pureName }],
}));
this.getTableInfo({ schemaName, pureName }).then((table) => {
console.log('Loading table info', schemaName, pureName);
this.setCache((cache) => ({
...cache,
loadingTables: cache.loadingTables.filter((x) => x.schemaName != schemaName || x.pureName != pureName),
tables: {
...cache.tables,
[uniqueName]: table,
@@ -173,7 +184,6 @@ export class TableGridDisplay extends GridDisplay {
});
}
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo): ReferenceActionResult {
const action = combineReferenceActions(
this.addJoinsFromExpandedColumns(select, this.columns, 'basetbl', displayedColumnInfo),

View File

@@ -6,7 +6,7 @@ export default function usePropsCompare(props) {
if (!prevProps) return;
for (const key of _.union(_.keys(props), _.keys(prevProps))) {
if (props[key] !== prevProps[key]) {
console.log(`Different prop value found: prop=${key}, old=${prevProps[key]}, new=${prevProps[key]}`);
console.log(`Different prop value found: prop=${key}, old, new`, prevProps[key], prevProps[key]);
}
}
}