From 7aa3521775cdc0dfb3516f5bce2608b8b6133f87 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 24 Oct 2022 15:42:47 -0500 Subject: [PATCH] Don't crash app home if count comes back null; don't crash table if no field named 'id' --- src/qqq/pages/app-home/index.tsx | 22 ++++++++++++++++++-- src/qqq/pages/entity-list/index.tsx | 32 +++++++++++++++-------------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/qqq/pages/app-home/index.tsx b/src/qqq/pages/app-home/index.tsx index fd17fc6..e14d8b4 100644 --- a/src/qqq/pages/app-home/index.tsx +++ b/src/qqq/pages/app-home/index.tsx @@ -55,6 +55,8 @@ function AppHome({app}: Props): JSX.Element const [reports, setReports] = useState([] as QReportMetaData[]); const [childApps, setChildApps] = useState([] as QAppMetaData[]); const [tableCounts, setTableCounts] = useState(new Map()); + const [tableCountNumbers, setTableCountNumbers] = useState(new Map()); + const [tableCountTexts, setTableCountTexts] = useState(new Map()); const [updatedTableCounts, setUpdatedTableCounts] = useState(new Date()); const [widgets, setWidgets] = useState([] as any[]); @@ -113,6 +115,8 @@ function AppHome({app}: Props): JSX.Element setChildApps(newChildApps); const tableCounts = new Map(); + const tableCountNumbers = new Map(); + const tableCountTexts = new Map(); newTables.forEach((table) => { tableCounts.set(table.name, {isLoading: true, value: null}); @@ -122,6 +126,20 @@ function AppHome({app}: Props): JSX.Element const count = await qController.count(table.name); tableCounts.set(table.name, {isLoading: false, value: count}); setTableCounts(tableCounts); + + if(count !== null && count !== undefined) + { + tableCountNumbers.set(table.name, count.toLocaleString()); + tableCountTexts.set(table.name, count === 1 ? "total record" : "total records"); + } + else + { + tableCountNumbers.set(table.name, "--"); + tableCountTexts.set(table.name, " "); + } + setTableCountNumbers(tableCountNumbers); + setTableCountTexts(tableCountTexts); + setUpdatedTableCounts(new Date()); }, 1); }); @@ -261,8 +279,8 @@ function AppHome({app}: Props): JSX.Element {table.iconName || app.iconName}}} direction="right" /> diff --git a/src/qqq/pages/entity-list/index.tsx b/src/qqq/pages/entity-list/index.tsx index 54206bd..aacc5ca 100644 --- a/src/qqq/pages/entity-list/index.tsx +++ b/src/qqq/pages/entity-list/index.tsx @@ -592,9 +592,26 @@ function EntityList({table, launchProcess}: Props): JSX.Element row[field.name] = value; }); + if(!row["id"]) + { + row["id"] = row[tableMetaData.primaryKeyField]; + } + rows.push(row); }); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // do this secondary check for columnsToRender - in case we didn't have any rows above, and our check for string isn't enough. // + // ... shouldn't this be just based on the field definition anyway... ? plus adornments? // + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + fields.forEach((field) => + { + if(field.possibleValueSourceName) + { + columnsToRender[field.name] = true; + } + }); + if(columnsModel.length == 0) { setupGridColumns(columnsToRender); @@ -877,21 +894,6 @@ function EntityList({table, launchProcess}: Props): JSX.Element return ""; } - function getRecordIdsForProcess(): string | QQueryFilter - { - if (selectFullFilterState === "filter") - { - return (buildQFilter(filterModel)); - } - - if (selectedIds.length > 0) - { - return (selectedIds.join(",")); - } - - return ""; - } - const openModalProcess = (process: QProcessMetaData = null) => { if (selectFullFilterState === "filter")