diff --git a/frontend/app/api/fixeddata/[dataType]/[[...slugs]]/route.ts b/frontend/app/api/fixeddata/[dataType]/[[...slugs]]/route.ts index 612a27ec..e456eb55 100644 --- a/frontend/app/api/fixeddata/[dataType]/[[...slugs]]/route.ts +++ b/frontend/app/api/fixeddata/[dataType]/[[...slugs]]/route.ts @@ -65,7 +65,7 @@ export async function GET( case 'personnel': paginatedQuery = ` SELECT SQL_CALC_FOUND_ROWS p.* - FROM ${schema}.${params.dataType} q + FROM ${schema}.${params.dataType} p JOIN ${schema}.census c ON p.CensusID = c.CensusID WHERE c.PlotID = ? AND c.PlotCensusNumber = ? LIMIT ?, ?;`; diff --git a/frontend/components/client/formcolumns.tsx b/frontend/components/client/formcolumns.tsx index 20461a0c..fecacfbe 100644 --- a/frontend/components/client/formcolumns.tsx +++ b/frontend/components/client/formcolumns.tsx @@ -1,6 +1,6 @@ 'use client'; -import { GridColDef, GridRenderEditCellParams, useGridApiContext, useGridApiRef } from '@mui/x-data-grid'; +import { GridColDef, GridRenderEditCellParams, useGridApiContext } from '@mui/x-data-grid'; import { areaSelectionOptions, unitSelectionOptions } from '@/config/macros'; import { formatHeader } from '@/components/client/datagridcolumns'; import moment from 'moment/moment'; @@ -12,25 +12,44 @@ import { AttributeStatusOptions } from '@/config/sqlrdsdefinitions/core'; import { styled } from '@mui/joy/styles'; import { CheckCircleOutlined } from '@mui/icons-material'; -const renderDatePicker = (params: GridRenderEditCellParams) => { +export const renderDatePicker = (params: GridRenderEditCellParams) => { const convertedValue = params.row.date ? moment(params.row.date, 'YYYY-MM-DD') : null; if (!convertedValue) return <>; return ( - - + + ); }; -const renderEditDatePicker = (params: GridRenderEditCellParams) => { - const apiRef = useGridApiRef(); +export const renderEditDatePicker = (params: GridRenderEditCellParams) => { + const apiRef = useGridApiContext(); const { id, row } = params; return ( - + { apiRef.current.setEditCellValue({ id, field: 'date', value: newValue ? newValue.format('YYYY-MM-DD') : null }); @@ -344,7 +363,6 @@ export const AttributesFormGridColumns: GridColDef[] = [ field: 'code', headerName: 'Code', headerClassName: 'header', - minWidth: 250, flex: 1, editable: true }, @@ -352,7 +370,6 @@ export const AttributesFormGridColumns: GridColDef[] = [ field: 'description', headerName: 'Description', headerClassName: 'header', - minWidth: 250, flex: 1, editable: true }, @@ -360,7 +377,6 @@ export const AttributesFormGridColumns: GridColDef[] = [ field: 'status', headerName: 'Status', headerClassName: 'header', - minWidth: 250, flex: 1, editable: true // This is temporarily being suspended -- it's a nice to have, not a need to have @@ -382,7 +398,6 @@ export const PersonnelFormGridColumns: GridColDef[] = [ field: 'firstname', headerName: 'First Name', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -391,7 +406,6 @@ export const PersonnelFormGridColumns: GridColDef[] = [ field: 'lastname', headerName: 'Last Name', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -400,7 +414,6 @@ export const PersonnelFormGridColumns: GridColDef[] = [ field: 'role', headerName: 'Role', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -409,7 +422,6 @@ export const PersonnelFormGridColumns: GridColDef[] = [ field: 'roledescription', headerName: 'Role Description', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -430,7 +442,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'spcode', headerName: 'Species Code', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -439,7 +450,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'family', headerName: 'Family', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -448,7 +458,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'genus', headerName: 'Genus', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -457,7 +466,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'species', headerName: 'Species', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -466,7 +474,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'subspecies', headerName: 'Subspecies', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -475,7 +482,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'idlevel', headerName: 'ID Level', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -484,7 +490,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'authority', headerName: 'Authority', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -493,7 +498,6 @@ export const SpeciesFormGridColumns: GridColDef[] = [ field: 'subspeciesauthority', headerName: 'Subspecies Authority', headerClassName: 'header', - minWidth: 250, flex: 1, align: 'left', editable: true @@ -681,10 +685,10 @@ export const MeasurementsFormGridColumns: GridColDef[] = [ }, { field: 'coordinateunit', - headerName: 'Coordinate Units', + headerName: '<= Units', headerClassName: 'header', - renderHeader: () => formatHeader('Coordinate', 'Units'), - flex: 1.5, + // renderHeader: () => formatHeader('Coordinate', 'Units'), + flex: 0.5, align: 'center', editable: true, renderEditCell: params => @@ -700,10 +704,10 @@ export const MeasurementsFormGridColumns: GridColDef[] = [ }, { field: 'dbhunit', - headerName: 'DBH Units', + headerName: '<= Units', headerClassName: 'header', - renderHeader: () => formatHeader('DBH', 'Units'), - flex: 1.5, + // renderHeader: () => formatHeader('DBH', 'Units'), + flex: 0.5, align: 'center', editable: true, renderEditCell: params => @@ -719,30 +723,12 @@ export const MeasurementsFormGridColumns: GridColDef[] = [ }, { field: 'homunit', - headerName: 'HOM Units', + headerName: '<= Units', headerClassName: 'header', - renderHeader: () => formatHeader('HOM', 'Units'), - flex: 1.5, + // renderHeader: () => formatHeader('HOM', 'Units'), + flex: 0.5, align: 'center', editable: true, renderEditCell: params => - }, - { - field: 'date', - headerName: 'Date', - headerClassName: 'header', - flex: 1, - align: 'center', - editable: true, - renderCell: renderDatePicker, - renderEditCell: renderEditDatePicker - }, - { - field: 'codes', - headerName: 'Codes', - headerClassName: 'header', - flex: 1, - align: 'center', - editable: true } ]; diff --git a/frontend/components/datagrids/applications/msvdatagrid.tsx b/frontend/components/datagrids/applications/msvdatagrid.tsx index ea276536..92296e4c 100644 --- a/frontend/components/datagrids/applications/msvdatagrid.tsx +++ b/frontend/components/datagrids/applications/msvdatagrid.tsx @@ -3,7 +3,6 @@ import { useOrgCensusContext, usePlotContext, useSiteContext } from '@/app/contexts/userselectionprovider'; import React, { useEffect, useState } from 'react'; import { GridRowModes, GridRowModesModel, GridRowsProp } from '@mui/x-data-grid'; -import { Alert, AlertProps } from '@mui/material'; import { randomId } from '@mui/x-data-grid-generator'; import { Box, Button, Snackbar, Stack, Typography } from '@mui/joy'; import UploadParentModal from '@/components/uploadsystemhelpers/uploadparentmodal'; @@ -13,6 +12,7 @@ import { FormType } from '@/config/macros/formdetails'; import { MeasurementsSummaryRDS } from '@/config/sqlrdsdefinitions/views'; import MultilineModal from '@/components/datagrids/applications/multiline/multilinemodal'; import { useLoading } from '@/app/contexts/loadingprovider'; +import { Alert, AlertProps, AlertTitle, Collapse } from '@mui/material'; const initialMeasurementsSummaryViewRDSRow: MeasurementsSummaryRDS = { id: 0, @@ -50,6 +50,7 @@ export default function MeasurementsSummaryViewDataGrid() { const [isManualEntryFormOpen, setIsManualEntryFormOpen] = useState(false); const [triggerGlobalError, setTriggerGlobalError] = useState(false); const [globalError, setGlobalError] = useState(null); + const [openAlert, setOpenAlert] = useState(false); const [rows, setRows] = React.useState([initialMeasurementsSummaryViewRDSRow] as GridRowsProp); const [rowCount, setRowCount] = useState(0); @@ -156,7 +157,7 @@ export default function MeasurementsSummaryViewDataGrid() { isUploadModalOpen={isUploadModalOpen} handleCloseUploadModal={() => { setIsUploadModalOpen(false); - setRefresh(true); + setOpenAlert(true); }} formType={FormType.measurements} /> @@ -164,7 +165,7 @@ export default function MeasurementsSummaryViewDataGrid() { isManualEntryFormOpen={isManualEntryFormOpen} handleCloseManualEntryForm={() => { setIsManualEntryFormOpen(false); - setRefresh(true); + setOpenAlert(true); }} formType={'measurements'} /> @@ -190,6 +191,20 @@ export default function MeasurementsSummaryViewDataGrid() { setShouldAddRowAfterFetch={setShouldAddRowAfterFetch} addNewRowToGrid={addNewRowToGrid} /> + + setOpenAlert(false)} + sx={{ display: 'flex', flex: 1, alignSelf: 'center', justifySelf: 'center', alignItems: 'center', justifyContent: 'center' }} + > + setOpenAlert(false)} severity="warning"> + Changes detected! + Please press the refresh button to update the grid. + + + ); } diff --git a/frontend/components/datagrids/isolatedmultilinedatagridcommons.tsx b/frontend/components/datagrids/isolatedmultilinedatagridcommons.tsx index af98f7a9..b9c267fb 100644 --- a/frontend/components/datagrids/isolatedmultilinedatagridcommons.tsx +++ b/frontend/components/datagrids/isolatedmultilinedatagridcommons.tsx @@ -14,6 +14,7 @@ import { getColumnVisibilityModel } from '@/config/datagridhelpers'; import { useOrgCensusContext, usePlotContext, useSiteContext } from '@/app/contexts/userselectionprovider'; import { FileRow, FileRowSet } from '@/config/macros/formdetails'; import { AttributeStatusOptions } from '@/config/sqlrdsdefinitions/core'; +import { renderDatePicker, renderEditDatePicker } from '@/components/client/formcolumns'; export interface IsolatedDataGridCommonProps { gridType: string; @@ -85,7 +86,24 @@ export default function IsolatedMultilineDataGridCommons(props: Readonly row._action === 'delete'); const rowsToSave = Object.values(unsavedChangesRef.current.unsavedRows).filter(row => row._action !== 'delete'); @@ -134,7 +151,6 @@ export default function IsolatedMultilineDataGridCommons(props: Readonly 'auto'} />