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

View File

@@ -162,9 +162,20 @@ export class TableGridDisplay extends GridDisplay {
requireFkTarget(column: DisplayColumn) { requireFkTarget(column: DisplayColumn) {
const { uniqueName, foreignKey } = column; 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) => ({ this.setCache((cache) => ({
...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: { tables: {
...cache.tables, ...cache.tables,
[uniqueName]: table, [uniqueName]: table,
@@ -173,7 +184,6 @@ export class TableGridDisplay extends GridDisplay {
}); });
} }
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo): ReferenceActionResult { processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo): ReferenceActionResult {
const action = combineReferenceActions( const action = combineReferenceActions(
this.addJoinsFromExpandedColumns(select, this.columns, 'basetbl', displayedColumnInfo), this.addJoinsFromExpandedColumns(select, this.columns, 'basetbl', displayedColumnInfo),

View File

@@ -6,7 +6,7 @@ export default function usePropsCompare(props) {
if (!prevProps) return; if (!prevProps) return;
for (const key of _.union(_.keys(props), _.keys(prevProps))) { for (const key of _.union(_.keys(props), _.keys(prevProps))) {
if (props[key] !== prevProps[key]) { 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]);
} }
} }
} }