From 6215e58e235145ae96790c4db3d631ca900fc892 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 10 Feb 2023 09:56:57 -0600 Subject: [PATCH] Set min height on record query table; fix some url bugs in query & view; add create to action menu on view. --- src/qqq/pages/records/query/RecordQuery.tsx | 188 ++++++++++---------- src/qqq/pages/records/view/RecordView.tsx | 22 ++- src/qqq/styles/qqq-override-styles.css | 5 + 3 files changed, 119 insertions(+), 96 deletions(-) diff --git a/src/qqq/pages/records/query/RecordQuery.tsx b/src/qqq/pages/records/query/RecordQuery.tsx index 2780a70..ade6cc5 100644 --- a/src/qqq/pages/records/query/RecordQuery.tsx +++ b/src/qqq/pages/records/query/RecordQuery.tsx @@ -89,7 +89,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element const location = useLocation(); const navigate = useNavigate(); - const pathParts = location.pathname.split("/"); + const pathParts = location.pathname.replace(/\/+$/, "").split("/"); //////////////////////////////////////////// // look for defaults in the local storage // @@ -995,6 +995,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element +
@@ -1131,103 +1132,104 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element return ( - {/* - // see above code that would use this - - */} - - {alertContent ? ( - - - { - setAlertContent(null); - }} - > - {alertContent} - - - ) : ( - "" - )} - { - (tableLabel && showSuccessfullyDeletedAlert) ? ( - - { - setShowSuccessfullyDeletedAlert(false); - }}> - {`${tableLabel} successfully deleted`} - - ) : null - } - - - - - - - - {renderActionsMenu} - +
+ {/* + // see above code that would use this + + */} + + {alertContent ? ( + + + { + setAlertContent(null); + }} + > + {alertContent} + + + ) : ( + "" + )} { - table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission && - + (tableLabel && showSuccessfullyDeletedAlert) ? ( + + { + setShowSuccessfullyDeletedAlert(false); + }}> + {`${tableLabel} successfully deleted`} + + ) : null } + + + + + + + + {renderActionsMenu} + + { + table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission && + + } - - - - "auto"} // maybe nice? wraps values in cells... - columns={columnsModel} - rowBuffer={10} - rowCount={totalRecords === null || totalRecords === undefined ? 0 : totalRecords} - onPageSizeChange={handleRowsPerPageChange} - onRowClick={handleRowClick} - onStateChange={handleStateChange} - density={density} - loading={loading} - filterModel={filterModel} - onFilterModelChange={handleFilterChange} - columnVisibilityModel={columnVisibilityModel} - onColumnVisibilityModelChange={handleColumnVisibilityChange} - onColumnOrderChange={handleColumnOrderChange} - onSelectionModelChange={selectionChanged} - onSortModelChange={handleSortChange} - sortingOrder={[ "asc", "desc" ]} - sortModel={columnSortModel} - getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")} - /> - - - - { - activeModalProcess && - closeModalProcess(event, reason)}> -
- -
-
- } + + + "auto"} // maybe nice? wraps values in cells... + columns={columnsModel} + rowBuffer={10} + rowCount={totalRecords === null || totalRecords === undefined ? 0 : totalRecords} + onPageSizeChange={handleRowsPerPageChange} + onRowClick={handleRowClick} + onStateChange={handleStateChange} + density={density} + loading={loading} + filterModel={filterModel} + onFilterModelChange={handleFilterChange} + columnVisibilityModel={columnVisibilityModel} + onColumnVisibilityModelChange={handleColumnVisibilityChange} + onColumnOrderChange={handleColumnOrderChange} + onSelectionModelChange={selectionChanged} + onSortModelChange={handleSortChange} + sortingOrder={[ "asc", "desc" ]} + sortModel={columnSortModel} + getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")} + /> + + + + { + activeModalProcess && + closeModalProcess(event, reason)}> +
+ +
+
+ } +
); } diff --git a/src/qqq/pages/records/view/RecordView.tsx b/src/qqq/pages/records/view/RecordView.tsx index 55416f5..37e3101 100644 --- a/src/qqq/pages/records/view/RecordView.tsx +++ b/src/qqq/pages/records/view/RecordView.tsx @@ -81,7 +81,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element const location = useLocation(); const navigate = useNavigate(); - const pathParts = location.pathname.split("/"); + const pathParts = location.pathname.replace(/\/+$/, "").split("/"); const tableName = table.name; const [asyncLoadInited, setAsyncLoadInited] = useState(false); @@ -122,6 +122,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element setNonT1TableSections([]); setTableProcesses([]); setTableSections(null); + setShowAudit(false); }; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -458,6 +459,14 @@ function RecordView({table, launchProcess}: Props): JSX.Element openModalProcess(process); } + let hasEditOrDelete = (table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission) || (table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission); + + function gotoCreate() + { + const path = `${pathParts.slice(0, -1).join("/")}/create`; + navigate(path); + } + const renderActionsMenu = ( + { + table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission && + gotoCreate()}> + add + Create New + + } { table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission && navigate("edit")}> @@ -492,14 +508,14 @@ function RecordView({table, launchProcess}: Props): JSX.Element Delete } - {tableProcesses.length > 0 && ((table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission) || (table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission)) && } + {tableProcesses.length > 0 && hasEditOrDelete && } {tableProcesses.map((process) => ( processClicked(process)}> {process.iconName ?? "arrow_forward"} {process.label} ))} - {tableProcesses.length > 0 && } + {(tableProcesses.length > 0 || hasEditOrDelete) && } navigate("dev")}> data_object Developer Mode diff --git a/src/qqq/styles/qqq-override-styles.css b/src/qqq/styles/qqq-override-styles.css index 4cabed0..587a3ea 100644 --- a/src/qqq/styles/qqq-override-styles.css +++ b/src/qqq/styles/qqq-override-styles.css @@ -24,6 +24,11 @@ white-space: normal; } +.recordQuery .MuiDataGrid-virtualScrollerContent +{ + min-height: calc(100vh - 450px) !important; +} + /* Disable red outlines on clicked cells */ .MuiDataGrid-cell:focus, .MuiDataGrid-columnHeader:focus,