From b4f8fb2e18c7b93cca974ea09866b322ff3b2815 Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Fri, 22 Nov 2024 11:41:29 -0600 Subject: [PATCH] CE-1946: minor updates to padding, fixes, etc --- src/qqq/components/forms/EntityForm.tsx | 8 ++--- .../components/widgets/DashboardWidgets.tsx | 7 ++-- .../widgets/misc/RecordGridWidget.tsx | 8 ++++- src/qqq/pages/records/view/RecordView.tsx | 35 ++++++++++++------- src/qqq/utils/HtmlUtils.ts | 3 +- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/qqq/components/forms/EntityForm.tsx b/src/qqq/components/forms/EntityForm.tsx index 1fbf720..1e08a00 100644 --- a/src/qqq/components/forms/EntityForm.tsx +++ b/src/qqq/components/forms/EntityForm.tsx @@ -818,9 +818,9 @@ function EntityForm(props: Props): JSX.Element { actions.setSubmitting(true); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // if there's a callback (e.g., for a modal nested on another create/edit screen), then just pass our data back there anre return. // - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // if there's a callback (e.g., for a modal nested on another create/edit screen), then just pass our data back there and return. // + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (props.onSubmitCallback) { props.onSubmitCallback(values); @@ -1290,7 +1290,7 @@ function EntityForm(props: Props): JSX.Element table={showEditChildForm.table} defaultValues={showEditChildForm.defaultValues} disabledFields={showEditChildForm.disabledFields} - onSubmitCallback={submitEditChildForm} + onSubmitCallback={props.onSubmitCallback ? props.onSubmitCallback : submitEditChildForm} overrideHeading={`${showEditChildForm.rowIndex != null ? "Editing" : "Creating New"} ${showEditChildForm.table.label}`} /> diff --git a/src/qqq/components/widgets/DashboardWidgets.tsx b/src/qqq/components/widgets/DashboardWidgets.tsx index e59ef5d..b62db37 100644 --- a/src/qqq/components/widgets/DashboardWidgets.tsx +++ b/src/qqq/components/widgets/DashboardWidgets.tsx @@ -107,7 +107,6 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco // modal form controls // ///////////////////////// const [showEditChildForm, setShowEditChildForm] = useState(null as any); - const [modalTable, setModalTable] = useState(null as QTableMetaData); let initialSelectedTab = 0; let selectedTabKey: string = null; @@ -340,13 +339,15 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco *******************************************************************************/ function openAddChildRecord(name: string, widgetData: any) { + let defaultValues = widgetData.defaultValuesForNewChildRecords; + let disabledFields = widgetData.disabledFieldsForNewChildRecords; if (!disabledFields) { disabledFields = widgetData.defaultValuesForNewChildRecords; } - doOpenEditChildForm(name, widgetData.childTableMetaData, null, null, disabledFields); + doOpenEditChildForm(name, widgetData.childTableMetaData, null, defaultValues, disabledFields); } @@ -714,7 +715,7 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco allowRecordDelete={widgetData[i]?.allowRecordDelete} deleteRecordCallback={(rowIndex) => deleteChildRecord(widgetMetaData.name, i, rowIndex)} editRecordCallback={(rowIndex) => openEditChildRecord(widgetMetaData.name, widgetData[i], rowIndex)} - addNewRecordCallback={() => openAddChildRecord(widgetMetaData.name, widgetData[i])} + addNewRecordCallback={widgetData[i]?.isInProcess ? () => openAddChildRecord(widgetMetaData.name, widgetData[i]) : null} widgetMetaData={widgetMetaData} data={widgetData[i]} /> diff --git a/src/qqq/components/widgets/misc/RecordGridWidget.tsx b/src/qqq/components/widgets/misc/RecordGridWidget.tsx index 0e088dd..09c3e02 100644 --- a/src/qqq/components/widgets/misc/RecordGridWidget.tsx +++ b/src/qqq/components/widgets/misc/RecordGridWidget.tsx @@ -295,6 +295,12 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo return (); } + let containerPadding = -3; + if (data?.isInProcess) + { + containerPadding = 0; + } + return ( - + { @@ -130,8 +130,8 @@ export function renderSectionOfFields(key: string, fieldNames: string[], tableMe /*************************************************************************** -** -***************************************************************************/ + ** + ***************************************************************************/ export function getVisibleJoinTables(tableMetaData: QTableMetaData): Set { const visibleJoinTables = new Set(); @@ -205,6 +205,8 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. const {accentColor, setPageHeader, tableMetaData, setTableMetaData, tableProcesses, setTableProcesses, dotMenuOpen, keyboardHelpOpen, helpHelpActive, recordAnalytics, userId: currentUserId} = useContext(QContext); + const CREATE_CHILD_KEY = "createChild"; + if (localStorage.getItem(tableVariantLocalStorageKey)) { tableVariant = JSON.parse(localStorage.getItem(tableVariantLocalStorageKey)); @@ -307,12 +309,19 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. /////////////////////////////////////////////////////////////////////////////////////////////// // the path for a process looks like: .../table/id/process // // the path for creating a child record looks like: .../table/id/createChild/:childTableName // + // the path for creating a child record in a process looks like: // + // .../table/id/processName#/createChild=... // /////////////////////////////////////////////////////////////////////////////////////////////// + let hasChildRecordKey = pathParts.some(p => p.includes(CREATE_CHILD_KEY)); + if (!hasChildRecordKey) + { + hasChildRecordKey = hashParts.some(h => h.includes(CREATE_CHILD_KEY)); + } - ////////////////////////////////////////////////////////////// - // if our tableName is in the -3 index, try to open process // - ////////////////////////////////////////////////////////////// - if (pathParts[pathParts.length - 3] === tableName) + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // if our tableName is in the -3 index, and there is no token for updating child records, try to open process // + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + if (!hasChildRecordKey && pathParts[pathParts.length - 3] === tableName) { const processName = pathParts[pathParts.length - 1]; const processList = allTableProcesses.filter(p => p.name.endsWith(processName)); @@ -349,7 +358,7 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. // if our table is in the -4 index, and there's `createChild` in the -2 index, try to open a createChild form // // e.g., person/42/createChild/address (to create an address under person 42) // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (pathParts[pathParts.length - 4] === tableName && pathParts[pathParts.length - 2] == "createChild") + if (pathParts[pathParts.length - 4] === tableName && pathParts[pathParts.length - 2] == CREATE_CHILD_KEY) { (async () => { @@ -368,7 +377,7 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. for (let i = 0; i < hashParts.length; i++) { const parts = hashParts[i].split("="); - if (parts.length > 1 && parts[0] == "createChild") + if (parts.length > 1 && parts[0] == CREATE_CHILD_KEY) { (async () => { @@ -490,7 +499,7 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. //////////////////////////////////////////////////////////////////////////// // if the component took in a record object, then we don't need to GET it // //////////////////////////////////////////////////////////////////////////// - if(overrideRecord) + if (overrideRecord) { record = overrideRecord; } @@ -826,12 +835,12 @@ function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX. { let shareDisabled = true; let disabledTooltipText = ""; - if(tableMetaData.shareableTableMetaData.thisTableOwnerIdFieldName && record) + if (tableMetaData.shareableTableMetaData.thisTableOwnerIdFieldName && record) { const ownerId = record.values.get(tableMetaData.shareableTableMetaData.thisTableOwnerIdFieldName); - if(ownerId != currentUserId) + if (ownerId != currentUserId) { - disabledTooltipText = `Only the owner of a ${tableMetaData.label} may share it.` + disabledTooltipText = `Only the owner of a ${tableMetaData.label} may share it.`; shareDisabled = true; } else diff --git a/src/qqq/utils/HtmlUtils.ts b/src/qqq/utils/HtmlUtils.ts index d83332d..538b272 100644 --- a/src/qqq/utils/HtmlUtils.ts +++ b/src/qqq/utils/HtmlUtils.ts @@ -75,7 +75,8 @@ export default class HtmlUtils { if (url.startsWith("http")) { - url += encodeURIComponent(`?response-content-disposition=attachment; ${filename}`); + const separator = url.includes("?") ? "&" : "?"; + url += encodeURIComponent(`${separator}response-content-disposition=attachment; ${filename}`); } const link = document.createElement("a");