Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search for modelKey #3922

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/src/app/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ export const MORECAST_MODEL_COLORS: ModelDetails = {
}
export type MoreCastModelColors = typeof MORECAST_MODEL_COLORS

export const modelColorClass = (params: Pick<GridCellParams | GridColumnHeaderParams, 'field'>) => {
export const modelColorClass = (params: Pick<GridCellParams | GridColumnHeaderParams, 'colDef' | 'field'>) => {
if (params.field.includes('Actual')) {
return ''
}
const stringKeys = Object.keys(MORECAST_MODEL_COLORS)
const modelKey = stringKeys.find(key => params.field.includes(key.toUpperCase()))
const modelKey = stringKeys.find(key => params.colDef.headerName?.startsWith(key.toUpperCase()))
return modelKey ? modelKey : ''
}

export const modelHeaderColorClass = (params: Pick<GridCellParams | GridColumnHeaderParams, 'field'>) => {
export const modelHeaderColorClass = (params: Pick<GridCellParams | GridColumnHeaderParams, 'colDef' | 'field'>) => {
const modelClass = modelColorClass(params)
return modelClass === '' ? modelClass : `${modelClass}-header`
}
4 changes: 2 additions & 2 deletions web/src/features/moreCast2/components/ColumnDefBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ export class ColumnDefBuilder implements ColDefGenerator, ForecastColDefGenerato
sortable: false,
type: 'number',
width: width ?? DEFAULT_COLUMN_WIDTH,
cellClassName: (params: Pick<GridCellParams, 'field'>) => {
cellClassName: (params: Pick<GridCellParams, 'colDef' | 'field'>) => {
return modelColorClass(params)
},
headerClassName: (params: Pick<GridColumnHeaderParams, 'field'>) => {
headerClassName: (params: Pick<GridColumnHeaderParams, 'colDef' | 'field'>) => {
return modelHeaderColorClass(params)
},
renderCell: (params: Pick<GridRenderCellParams, 'formattedValue'>) => {
Expand Down
Loading