Skip to content

Commit

Permalink
fix: update fuel select to turn white on activation
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-valiollahi committed Dec 19, 2024
1 parent 09dd16a commit 75d18e0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
19 changes: 11 additions & 8 deletions frontend/src/views/FuelExports/_schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,20 @@ export const fuelExportColDefs = (optionsData, errors, gridReady) => [
isFuelCodeScenario && !params.data.fuelCode

if (fuelCodeRequiredAndMissing) {
// If required and missing, force a red border
// Required scenario but missing a fuel code
style.borderColor = 'red'
style.backgroundColor = '#fff'
} else if (isFuelCodeScenario && fuelCodes.length > 1) {
style.backgroundColor = '#fff'
style.borderColor = 'unset'
} else if (isFuelCodeScenario && fuelCodes.length > 0) {
style.backgroundColor = '#fff'
style.borderColor = 'unset'
} else {
style.backgroundColor = '#f2f2f2'
}

const conditionalStyle =
fuelCodes.length > 0 &&
isFuelCodeScenario &&
!fuelCodeRequiredAndMissing
? { backgroundColor: '#fff', borderColor: 'unset' }
: { backgroundColor: '#f2f2f2' }
return { ...style, ...conditionalStyle }
return style
},
editable: (params) => {
const fuelTypeObj = optionsData?.fuelTypes?.find(
Expand Down
40 changes: 21 additions & 19 deletions frontend/src/views/OtherUses/_schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ export const otherUsesColDefs = (optionsData, errors) => [
cellEditorParams: (params) => {
const fuelType = optionsData?.fuelTypes?.find(
(obj) => params.data.fuelType === obj.fuelType
);
)
return {
options: fuelType ? fuelType.fuelCategories.map((item) => item.category) : [],
options: fuelType
? fuelType.fuelCategories.map((item) => item.category)
: [],
multiple: false,
disableCloseOnSelect: false,
freeSolo: false,
openOnFocus: true
};
}
},
suppressKeyboardEvent,
cellRenderer: (params) =>
Expand Down Expand Up @@ -153,22 +155,18 @@ export const otherUsesColDefs = (optionsData, errors) => [
const fuelCodeRequiredAndMissing =
isFuelCodeScenario && !params.data.fuelCode

// If required and missing, show red border
if (fuelCodeRequiredAndMissing) {
// Required scenario but missing a fuel code
style.borderColor = 'red'
style.backgroundColor = '#fff'
} else if (isFuelCodeScenario && fuelCodes.length > 0) {
style.backgroundColor = '#fff'
style.borderColor = style.borderColor || 'unset'
} else {
style.backgroundColor = '#f2f2f2'
}

const conditionalStyle =
isFuelCodeScenario &&
fuelCodes.length > 0 &&
!fuelCodeRequiredAndMissing
? {
backgroundColor: '#fff',
borderColor: style.borderColor || 'unset'
}
: { backgroundColor: '#f2f2f2' }

return { ...style, ...conditionalStyle }
return style
},
suppressKeyboardEvent,
minWidth: 150,
Expand Down Expand Up @@ -225,14 +223,18 @@ export const otherUsesColDefs = (optionsData, errors) => [
cellEditorParams: (params) => {
const fuelType = optionsData?.fuelTypes?.find(
(obj) => params.data.fuelType === obj.fuelType
);
const values = fuelType ? [fuelType.units] : [];
)
const values = fuelType ? [fuelType.units] : []
return {
values: values
};
}
},
cellRenderer: (params) => {
return params.value ? params.value : <BCTypography variant="body4">Select</BCTypography>;
return params.value ? (
params.value
) : (
<BCTypography variant="body4">Select</BCTypography>
)
},
cellStyle: (params) => StandardCellErrors(params, errors),
editable: true,
Expand Down

0 comments on commit 75d18e0

Please sign in to comment.