Skip to content

Commit

Permalink
Merge branch 'development-hotfixes' into forestgeo-app-development
Browse files Browse the repository at this point in the history
  • Loading branch information
siddheshraze committed Jan 2, 2025
2 parents 3a25f4d + fd7c301 commit 40a6c52
Show file tree
Hide file tree
Showing 14 changed files with 10,549 additions and 10,328 deletions.
47 changes: 39 additions & 8 deletions frontend/app/(hub)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import dynamic from 'next/dynamic';
import { Box, IconButton, Stack, Typography, useTheme } from '@mui/joy';
import Divider from '@mui/joy/Divider';
import { useLoading } from '@/app/contexts/loadingprovider';
import { useOrgCensusContext, usePlotContext, useSiteContext } from '@/app/contexts/userselectionprovider';
import {
useOrgCensusContext,
useOrgCensusDispatch,
usePlotContext,
usePlotDispatch,
useSiteContext,
useSiteDispatch
} from '@/app/contexts/userselectionprovider';
import { useOrgCensusListDispatch, usePlotListDispatch, useQuadratListDispatch, useSiteListDispatch } from '@/app/contexts/listselectionprovider';
import { getEndpointHeaderName, siteConfig } from '@/config/macros/siteconfigs';
import GithubFeedbackModal from '@/components/client/githubfeedbackmodal';
Expand Down Expand Up @@ -49,6 +56,9 @@ export default function HubLayout({ children }: { children: React.ReactNode }) {
const currentSite = useSiteContext();
const currentPlot = usePlotContext();
const currentCensus = useOrgCensusContext();
const siteDispatch = useSiteDispatch();
const plotDispatch = usePlotDispatch();
const censusDispatch = useOrgCensusDispatch();
const { data: session } = useSession();
const previousSiteRef = useRef<string | undefined>(undefined);
const previousPlotRef = useRef<number | undefined>(undefined);
Expand Down Expand Up @@ -205,16 +215,37 @@ export default function HubLayout({ children }: { children: React.ReactNode }) {

// Handle manual reset logic
useEffect(() => {
async function clearContexts() {
if (currentSite) {
if (siteDispatch) await siteDispatch({ site: undefined });
}
if (currentPlot) {
if (plotDispatch) await plotDispatch({ plot: undefined });
}
if (currentCensus) {
if (censusDispatch) await censusDispatch({ census: undefined });
}
}

if (manualReset) {
setLoading(true, 'Manual refresh beginning...');

// Reset all loading states
setSiteListLoaded(false);
setPlotListLoaded(false);
setCensusListLoaded(false);
setQuadratListLoaded(false);

setManualReset(false);
clearContexts()
.then(() => {
setSiteListLoaded(false);
})
.then(() => {
setPlotListLoaded(false);
})
.then(() => {
setCensusListLoaded(false);
})
.then(() => {
setQuadratListLoaded(false);
})
.finally(() => {
setManualReset(false);
});
}
}, [manualReset]);

Expand Down
28 changes: 19 additions & 9 deletions frontend/components/client/datagridcolumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { GridColDef, useGridApiRef } from '@mui/x-data-grid';
import React, { useEffect, useState } from 'react';
import { AttributeStatusOptions } from '@/config/sqlrdsdefinitions/core';
import { standardizeGridColumns } from '@/components/client/clientmacros';
import { customNumericOperators } from '@/components/datagrids/filtrationsystem';

export const formatHeader = (word1: string, word2: string) => (
<Stack direction={'column'} sx={{ width: '100%', alignItems: 'center', justifyContent: 'center' }}>
Expand Down Expand Up @@ -43,7 +44,8 @@ export const QuadratGridColumns: GridColDef[] = standardizeGridColumns([
valueFormatter: (value: any) => {
return Number(value).toFixed(2);
},
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'startY',
Expand All @@ -53,7 +55,8 @@ export const QuadratGridColumns: GridColDef[] = standardizeGridColumns([
valueFormatter: (value: any) => {
return Number(value).toFixed(2);
},
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'area',
Expand All @@ -63,7 +66,8 @@ export const QuadratGridColumns: GridColDef[] = standardizeGridColumns([
valueFormatter: (value: any) => {
return Number(value).toFixed(2);
},
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'dimensionX',
Expand All @@ -76,7 +80,8 @@ export const QuadratGridColumns: GridColDef[] = standardizeGridColumns([
if (isNaN(value)) parsedValue = 0.0;
return parsedValue.toFixed(2);
},
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'dimensionY',
Expand All @@ -89,7 +94,8 @@ export const QuadratGridColumns: GridColDef[] = standardizeGridColumns([
if (isNaN(value)) parsedValue = 0.0;
return parsedValue.toFixed(2);
},
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'quadratShape',
Expand Down Expand Up @@ -372,7 +378,8 @@ export const MeasurementsSummaryViewGridColumns: GridColDef[] = standardizeGridC
maxWidth: 100,
renderCell: renderStemXCell,
renderEditCell: renderEditStemXCell,
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'stemLocalY',
Expand All @@ -386,23 +393,26 @@ export const MeasurementsSummaryViewGridColumns: GridColDef[] = standardizeGridC
maxWidth: 100,
renderCell: renderStemYCell,
renderEditCell: renderEditStemYCell,
editable: true
editable: true,
filterOperators: customNumericOperators
},
{
field: 'measuredDBH',
headerName: 'DBH',
flex: 0.5,
editable: true,
renderCell: renderDBHCell,
renderEditCell: renderEditDBHCell
renderEditCell: renderEditDBHCell,
filterOperators: customNumericOperators
},
{
field: 'measuredHOM',
headerName: 'HOM',
flex: 0.5,
editable: true,
renderCell: renderHOMCell,
renderEditCell: renderEditHOMCell
renderEditCell: renderEditHOMCell,
filterOperators: customNumericOperators
},
{
field: 'description',
Expand Down
Loading

0 comments on commit 40a6c52

Please sign in to comment.