CE-1120: updated to handle errors on join tables (specifically was happening with deposco customer orders)

This commit is contained in:
Tim Chamberlain
2024-03-28 15:09:56 -05:00
parent f1826c81a9
commit 5e3991d9ae
2 changed files with 68 additions and 65 deletions

View File

@ -46,8 +46,6 @@ import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Modal from "@mui/material/Modal"; import Modal from "@mui/material/Modal";
import Tooltip from "@mui/material/Tooltip/Tooltip"; import Tooltip from "@mui/material/Tooltip/Tooltip";
import React, {useContext, useEffect, useState} from "react";
import {useLocation, useNavigate, useParams} from "react-router-dom";
import QContext from "QContext"; import QContext from "QContext";
import colors from "qqq/assets/theme/base/colors"; import colors from "qqq/assets/theme/base/colors";
import AuditBody from "qqq/components/audits/AuditBody"; import AuditBody from "qqq/components/audits/AuditBody";
@ -65,6 +63,8 @@ import Client from "qqq/utils/qqq/Client";
import ProcessUtils from "qqq/utils/qqq/ProcessUtils"; import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
import TableUtils from "qqq/utils/qqq/TableUtils"; import TableUtils from "qqq/utils/qqq/TableUtils";
import ValueUtils from "qqq/utils/qqq/ValueUtils"; import ValueUtils from "qqq/utils/qqq/ValueUtils";
import React, {useContext, useEffect, useState} from "react";
import {useLocation, useNavigate, useParams} from "react-router-dom";
const qController = Client.getInstance(); const qController = Client.getInstance();
@ -166,50 +166,50 @@ function RecordView({table, launchProcess}: Props): JSX.Element
{ {
if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission) if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
{ {
e.preventDefault() e.preventDefault();
gotoCreate(); gotoCreate();
} }
else if (!e.metaKey && e.key === "e" && table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission) else if (!e.metaKey && e.key === "e" && table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission)
{ {
e.preventDefault() e.preventDefault();
navigate("edit"); navigate("edit");
} }
else if (!e.metaKey && e.key === "c" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission) else if (!e.metaKey && e.key === "c" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
{ {
e.preventDefault() e.preventDefault();
navigate("copy"); navigate("copy");
} }
else if (!e.metaKey && e.key === "d" && table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission) else if (!e.metaKey && e.key === "d" && table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission)
{ {
e.preventDefault() e.preventDefault();
handleClickDeleteButton(); handleClickDeleteButton();
} }
else if (!e.metaKey && e.key === "a" && metaData && metaData.tables.has("audit")) else if (!e.metaKey && e.key === "a" && metaData && metaData.tables.has("audit"))
{ {
e.preventDefault() e.preventDefault();
navigate("#audit"); navigate("#audit");
} }
} }
} };
document.addEventListener("keydown", down) document.addEventListener("keydown", down);
return () => return () =>
{ {
document.removeEventListener("keydown", down) document.removeEventListener("keydown", down);
} };
}, [dotMenuOpen, keyboardHelpOpen, showEditChildForm, showAudit, metaData, location]) }, [dotMenuOpen, keyboardHelpOpen, showEditChildForm, showAudit, metaData, location]);
const gotoCreate = () => const gotoCreate = () =>
{ {
const path = `${pathParts.slice(0, -1).join("/")}/create`; const path = `${pathParts.slice(0, -1).join("/")}/create`;
navigate(path); navigate(path);
} };
const gotoEdit = () => const gotoEdit = () =>
{ {
const path = `${pathParts.slice(0, -1).join("/")}/${record.values.get(table.primaryKeyField)}/edit`; const path = `${pathParts.slice(0, -1).join("/")}/${record.values.get(table.primaryKeyField)}/edit`;
navigate(path); navigate(path);
} };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// monitor location changes - if we've clicked a link from viewing one record to viewing another, // // monitor location changes - if we've clicked a link from viewing one record to viewing another, //
@ -349,7 +349,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
{ {
visibleJoinTables.add(tableForField.name); visibleJoinTables.add(tableForField.name);
} }
}) });
} }
return (visibleJoinTables); return (visibleJoinTables);
@ -361,15 +361,15 @@ function RecordView({table, launchProcess}: Props): JSX.Element
*******************************************************************************/ *******************************************************************************/
const getSectionHelp = (section: QTableSection) => const getSectionHelp = (section: QTableSection) =>
{ {
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"] const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
const formattedHelpContent = <HelpContent helpContents={section.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />; const formattedHelpContent = <HelpContent helpContents={section.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />;
return formattedHelpContent && ( return formattedHelpContent && (
<Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}> <Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}>
{formattedHelpContent} {formattedHelpContent}
</Box> </Box>
) );
} };
if (!asyncLoadInited) if (!asyncLoadInited)
@ -401,11 +401,11 @@ function RecordView({table, launchProcess}: Props): JSX.Element
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// load processes that the routing needs to respect // // load processes that the routing needs to respect //
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
const allTableProcesses = ProcessUtils.getProcessesForTable(metaData, tableName, true) // these include hidden ones (e.g., to find the bulks) const allTableProcesses = ProcessUtils.getProcessesForTable(metaData, tableName, true); // these include hidden ones (e.g., to find the bulks)
const runRecordScriptProcess = metaData?.processes.get("runRecordScript"); const runRecordScriptProcess = metaData?.processes.get("runRecordScript");
if (runRecordScriptProcess) if (runRecordScriptProcess)
{ {
allTableProcesses.unshift(runRecordScriptProcess) allTableProcesses.unshift(runRecordScriptProcess);
} }
setAllTableProcesses(allTableProcesses); setAllTableProcesses(allTableProcesses);
@ -522,13 +522,15 @@ function RecordView({table, launchProcess}: Props): JSX.Element
section.fieldNames.map((fieldName: string) => section.fieldNames.map((fieldName: string) =>
{ {
let [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName); let [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
if (field != null)
{
let label = field.label; let label = field.label;
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"] const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles); const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles);
const formattedHelpContent = <HelpContent helpContents={field.helpContents} roles={helpRoles} heading={label} helpContentKey={`table:${tableName};field:${fieldName}`} />; const formattedHelpContent = <HelpContent helpContents={field.helpContents} roles={helpRoles} heading={label} helpContentKey={`table:${tableName};field:${fieldName}`} />;
const labelElement = <Typography variant="button" textTransform="none" fontWeight="bold" pr={1} color="rgb(52, 71, 103)" sx={{cursor: "default"}}>{label}:</Typography> const labelElement = <Typography variant="button" textTransform="none" fontWeight="bold" pr={1} color="rgb(52, 71, 103)" sx={{cursor: "default"}}>{label}:</Typography>;
return ( return (
<Box key={fieldName} flexDirection="row" pr={2}> <Box key={fieldName} flexDirection="row" pr={2}>
@ -542,7 +544,8 @@ function RecordView({table, launchProcess}: Props): JSX.Element
</Typography> </Typography>
</> </>
</Box> </Box>
) );
}
}) })
} }
</Box> </Box>
@ -603,9 +606,9 @@ function RecordView({table, launchProcess}: Props): JSX.Element
setWarningMessage(state["warning"]); setWarningMessage(state["warning"]);
} }
delete state["createSuccess"] delete state["createSuccess"];
delete state["updateSuccess"] delete state["updateSuccess"];
delete state["warning"] delete state["warning"];
window.history.replaceState(state, ""); window.history.replaceState(state, "");
} }

View File

@ -110,7 +110,7 @@ class TableUtils
return ([tableMetaData.fields.get(fieldName), tableMetaData]); return ([tableMetaData.fields.get(fieldName), tableMetaData]);
} }
return (null); return [null, null];
} }
@ -133,7 +133,7 @@ class TableUtils
catch (e) catch (e)
{ {
console.log(`Error getting full field label for ${fieldName} in table ${tableMetaData?.name}: ${e}`); console.log(`Error getting full field label for ${fieldName} in table ${tableMetaData?.name}: ${e}`);
return fieldName return fieldName;
} }
} }