diff --git a/package.json b/package.json index d7d9708..168d3d0 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "@fullcalendar/interaction": "5.10.0", "@fullcalendar/react": "5.10.0", "@fullcalendar/timegrid": "5.10.0", - "@kingsrook/qqq-frontend-core": "1.0.24", + "@kingsrook/qqq-frontend-core": "1.0.25", "@mui/icons-material": "5.4.1", "@mui/material": "5.4.1", "@mui/styled-engine": "5.4.1", "@mui/styles": "5.10.7", - "@mui/x-data-grid": "5.13.0", - "@mui/x-data-grid-pro": "5.13.0", + "@mui/x-data-grid": "5.17.6", + "@mui/x-data-grid-pro": "5.17.6", "@mui/x-license-pro": "5.12.3", "@react-jvectormap/core": "1.0.1", "@react-jvectormap/unitedstates": "1.0.1", diff --git a/src/qqq/components/EntityForm/index.tsx b/src/qqq/components/EntityForm/index.tsx index a6689ef..7ee6160 100644 --- a/src/qqq/components/EntityForm/index.tsx +++ b/src/qqq/components/EntityForm/index.tsx @@ -20,6 +20,7 @@ */ import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; +import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType"; import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData"; import {QTableSection} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableSection"; import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord"; @@ -42,6 +43,7 @@ import MDBox from "qqq/components/Temporary/MDBox"; import MDTypography from "qqq/components/Temporary/MDTypography"; import QClient from "qqq/utils/QClient"; import QTableUtils from "qqq/utils/QTableUtils"; +import QValueUtils from "qqq/utils/QValueUtils"; interface Props { @@ -120,9 +122,10 @@ function EntityForm({table, id}: Props): JSX.Element ///////////////////////////////////////////////////////////////////////////////// // if doing an edit, fetch the record and pre-populate the form values from it // ///////////////////////////////////////////////////////////////////////////////// + let record: QRecord = null; if (id !== null) { - const record = await qController.get(tableName, id); + record = await qController.get(tableName, id); setRecord(record); setFormTitle(`Edit ${tableMetaData?.label}: ${record?.recordLabel}`); setPageHeader(`Edit ${tableMetaData?.label}: ${record?.recordLabel}`); @@ -130,6 +133,10 @@ function EntityForm({table, id}: Props): JSX.Element tableMetaData.fields.forEach((fieldMetaData, key) => { initialValues[key] = record.values.get(key); + if(fieldMetaData.type == QFieldType.DATE_TIME) + { + initialValues[key] = QValueUtils.formatDateTimeValueForForm(record.values.get(key)); + } }); setFormValues(formValues); @@ -173,6 +180,24 @@ function EntityForm({table, id}: Props): JSX.Element { sectionDynamicFormFields.push(dynamicFormFields[fieldName]); } + + ///////////////////////////////////////// + // add props for possible value fields // + ///////////////////////////////////////// + if(field.possibleValueSourceName) + { + let initialDisplayValue = null; + if(record && record.displayValues) + { + initialDisplayValue = record.displayValues.get(field.name); + } + dynamicFormFields[fieldName].possibleValueProps = + { + isPossibleValue: true, + tableName: tableName, + initialDisplayValue: initialDisplayValue, + }; + } } if (sectionDynamicFormFields.length === 0) @@ -245,7 +270,9 @@ function EntityForm({table, id}: Props): JSX.Element }) .catch((error) => { - setAlertContent(error.response.data.error); + console.log("Caught:"); + console.log(error); + setAlertContent(error.message); }); } else @@ -259,7 +286,7 @@ function EntityForm({table, id}: Props): JSX.Element }) .catch((error) => { - setAlertContent(error.response.data.error); + setAlertContent(error.message); }); } })(); @@ -298,7 +325,7 @@ function EntityForm({table, id}: Props): JSX.Element