-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task/empty cell validation morecast (#3982)
allows ModelChoice.NULL for default precip values
- Loading branch information
Showing
24 changed files
with
625 additions
and
280 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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,54 @@ | ||
import { theme } from '@/app/theme' | ||
import InvalidCellToolTip from '@/features/moreCast2/components/InvalidCellToolTip' | ||
import { TextField } from '@mui/material' | ||
import { GridRenderCellParams } from '@mui/x-data-grid-pro' | ||
import React from 'react' | ||
|
||
interface ValidatedCellProps { | ||
disabled: boolean | ||
label: string | ||
error: boolean | ||
invalid: string | ||
value: Pick<GridRenderCellParams, 'formattedValue'> | ||
} | ||
|
||
const ValidatedGrassCureForecastCell = ({ disabled, label, value, invalid, error }: ValidatedCellProps) => { | ||
const testTag = error ? 'validated-forecast-cell-error' : 'validated-forecast-cell' | ||
return ( | ||
<InvalidCellToolTip invalid={invalid}> | ||
<TextField | ||
data-testid={testTag} | ||
disabled={disabled} | ||
size="small" | ||
label={label} | ||
InputLabelProps={{ | ||
shrink: true | ||
}} | ||
sx={{ | ||
'& .MuiOutlinedInput-root': { | ||
backgroundColor: `${theme.palette.common.white}`, | ||
'& fieldset': { | ||
borderColor: error ? theme.palette.error.main : '#737373', | ||
borderWidth: '2px' | ||
}, | ||
'&:hover fieldset': { | ||
borderColor: error ? theme.palette.error.main : '#737373' | ||
}, | ||
'&.Mui-focused fieldset': { | ||
borderColor: error ? theme.palette.error.main : '#737373', | ||
borderWidth: '2px' | ||
} | ||
}, | ||
'& .Mui-disabled': { | ||
'& fieldset': { | ||
borderWidth: '1px' | ||
} | ||
} | ||
}} | ||
value={value} | ||
></TextField> | ||
</InvalidCellToolTip> | ||
) | ||
} | ||
|
||
export default React.memo(ValidatedGrassCureForecastCell) |
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
22 changes: 22 additions & 0 deletions
22
web/src/features/moreCast2/components/ValidatedGrassCureForecastCell.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,22 @@ | ||
import React from 'react' | ||
import { GridRenderCellParams } from '@mui/x-data-grid-pro' | ||
import ValidatedCell from '@/features/moreCast2/components/ValidatedCell' | ||
import { Box } from '@mui/material' | ||
|
||
interface ValidatedGrassCureForecastCellProps { | ||
disabled: boolean | ||
label: string | ||
value: Pick<GridRenderCellParams, 'formattedValue'> | ||
validator?: (value: string) => string | ||
} | ||
|
||
const ValidatedGrassCureForecastCell = ({ disabled, label, value, validator }: ValidatedGrassCureForecastCellProps) => { | ||
const error = validator ? validator(value as string) : '' | ||
return ( | ||
<Box data-testid="validated-gc-forecast-cell"> | ||
<ValidatedCell disabled={disabled} label={label} error={error !== ''} invalid={error} value={value} /> | ||
</Box> | ||
) | ||
} | ||
|
||
export default React.memo(ValidatedGrassCureForecastCell) |
28 changes: 28 additions & 0 deletions
28
web/src/features/moreCast2/components/ValidatedWindDirectionForecastCell.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,28 @@ | ||
import { Grid } from '@mui/material' | ||
import { GridRenderCellParams } from '@mui/x-data-grid-pro' | ||
import ValidatedCell from '@/features/moreCast2/components/ValidatedCell' | ||
|
||
interface ForecastCellProps { | ||
disabled: boolean | ||
label: string | ||
value: Pick<GridRenderCellParams, 'formattedValue'> | ||
validator?: (value: string) => string | ||
} | ||
|
||
const ValidatedWindDirectionForecastCell = ({ disabled, label, value, validator }: ForecastCellProps) => { | ||
const error = validator ? validator(value as string) : '' | ||
|
||
return ( | ||
<Grid | ||
container | ||
sx={{ justifyContent: 'center', alignItems: 'center' }} | ||
data-testid="validated-winddir-forecast-cell" | ||
> | ||
<Grid item xs={8}> | ||
<ValidatedCell disabled={disabled} label={label} value={value} error={error !== ''} invalid={error} /> | ||
</Grid> | ||
</Grid> | ||
) | ||
} | ||
|
||
export default ValidatedWindDirectionForecastCell |
Oops, something went wrong.