Fixed bug where the grid columns, etc, could get out of sync (in the dishwasher) w/ the table, when doing certain Link operations (discovered from run-record-script process result screen w/ a filter link)

This commit is contained in:
2023-03-15 17:05:04 -05:00
parent bb122ed23a
commit ef51b7747f

View File

@ -285,9 +285,23 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
// if we didn't open a process... not sure what we do in the table/query use-case // // if we didn't open a process... not sure what we do in the table/query use-case //
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
setActiveModalProcess(null); setActiveModalProcess(null);
}, [ location , tableMetaData]);
}, [location , tableMetaData]);
///////////////////////////////////////////////////////////////////////
// any time these are out of sync, it means we need to reload things //
///////////////////////////////////////////////////////////////////////
if(tableMetaData && tableMetaData.name !== tableName)
{
console.log(" it looks like we changed tables - try to reload the things");
setTableMetaData(null)
setColumnSortModel([]);
setColumnVisibilityModel({});
setColumnsModel([]);
setFilterModel({items: []});
setDefaultFilterLoaded(false);
setRows([]);
}
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
// note - important to take tableMetaData as a param, even though it's a state var, as the // // note - important to take tableMetaData as a param, even though it's a state var, as the //
@ -301,27 +315,13 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
return(filter); return(filter);
}; };
const getTableMetaData = async (): Promise<QTableMetaData> =>
{
if(tableMetaData !== null)
{
return(new Promise((resolve) =>
{
resolve(tableMetaData)
}));
}
return (qController.loadTableMetaData(tableName));
}
const updateTable = () => const updateTable = () =>
{ {
setLoading(true); setLoading(true);
setRows([]); setRows([]);
(async () => (async () =>
{ {
const tableMetaData = await getTableMetaData(); const tableMetaData = await qController.loadTableMetaData(tableName);
setPageHeader(tableMetaData.label); setPageHeader(tableMetaData.label);
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////