-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. minor enhancements to the measurements-oriented datagrid to displa…
…y viewfulltable. 2. global formatting and adjustments
- Loading branch information
1 parent
ff819f8
commit 320ac7c
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
frontend/components/datagrids/applications/viewfulltabledatagrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// viewfulltable view datagrid | ||
'use client'; | ||
|
||
import { initialViewFullTableViewRDS } from '@/config/sqlrdsdefinitions/views/viewfulltableviewrds'; | ||
import { Box, Typography } from '@mui/joy'; | ||
import { AlertProps } from '@mui/material'; | ||
import { GridRowsProp } from '@mui/x-data-grid'; | ||
import { randomId } from '@mui/x-data-grid-generator'; | ||
import { useSession } from 'next-auth/react'; | ||
import { useState } from 'react'; | ||
import { ViewFullTableGridColumns } from '@/components/client/datagridcolumns'; | ||
import MeasurementSummaryGrid from '@/components/datagrids/msvdatagrid'; | ||
|
||
export default function ViewFullTableDataGrid() { | ||
const [rows, setRows] = useState<GridRowsProp>([initialViewFullTableViewRDS] as GridRowsProp); | ||
const [rowCount, setRowCount] = useState(0); | ||
const [rowModesModel, setRowModesModel] = useState({}); | ||
const [snackbar, setSnackbar] = useState<Pick<AlertProps, 'children' | 'severity'> | null>(null); | ||
const [refresh, setRefresh] = useState(false); | ||
const [paginationModel, setPaginationModel] = useState({ | ||
page: 0, | ||
pageSize: 10 | ||
}); | ||
const [isNewRowAdded, setIsNewRowAdded] = useState(false); | ||
const [shouldAddRowAfterFetch, setShouldAddRowAfterFetch] = useState(false); | ||
const { data: session } = useSession(); | ||
|
||
const addNewRowToGrid = () => { | ||
const id = randomId(); | ||
const newRow = { | ||
...initialViewFullTableViewRDS, | ||
id, | ||
isNew: true | ||
}; | ||
|
||
setRows(oldRows => [...(oldRows ?? []), newRow]); | ||
setRowModesModel(oldModel => ({ | ||
...oldModel, | ||
[id]: { mode: 'edit', fieldToFocus: 'speciesCode' } | ||
})); | ||
console.log('viewfulltableview addnewrowtogrid triggered'); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
mb: 3, | ||
width: '100%', | ||
flexDirection: 'column' | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
width: '100%', | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
backgroundColor: 'warning.main', | ||
borderRadius: '4px', | ||
p: 2 | ||
}} | ||
> | ||
<Box sx={{ flexGrow: 1 }}> | ||
{session?.user.userStatus !== 'fieldcrew' && ( | ||
<Typography level="title-lg" sx={{ color: '#ffa726' }}> | ||
Note: ADMINISTRATOR VIEW | ||
</Typography> | ||
)} | ||
</Box> | ||
</Box> | ||
|
||
<MeasurementSummaryGrid | ||
gridType="viewfulltable" | ||
gridColumns={ViewFullTableGridColumns} | ||
rows={rows} | ||
setRows={setRows} | ||
rowCount={rowCount} | ||
setRowCount={setRowCount} | ||
rowModesModel={rowModesModel} | ||
setRowModesModel={setRowModesModel} | ||
snackbar={snackbar} | ||
setSnackbar={setSnackbar} | ||
refresh={refresh} | ||
setRefresh={setRefresh} | ||
paginationModel={paginationModel} | ||
setPaginationModel={setPaginationModel} | ||
isNewRowAdded={isNewRowAdded} | ||
setIsNewRowAdded={setIsNewRowAdded} | ||
shouldAddRowAfterFetch={shouldAddRowAfterFetch} | ||
setShouldAddRowAfterFetch={setShouldAddRowAfterFetch} | ||
addNewRowToGrid={addNewRowToGrid} | ||
/> | ||
</Box> | ||
</> | ||
); | ||
} |