Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into fix/kevin-1514
Browse files Browse the repository at this point in the history
  • Loading branch information
prv-proton authored Dec 23, 2024
2 parents 4735230 + e0a352f commit f1e2249
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
10 changes: 0 additions & 10 deletions frontend/src/views/FuelCodes/AddFuelCode/AddEditFuelCode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ const AddEditFuelCodeBase = () => {
)
}
setRowData([transformedData])
} else {
setRowData([
{
id: uuid(),
prefixId: 1,
fuelSuffix: optionsData?.fuelCodePrefixes?.find(
(item) => item.prefix === 'BCLCF'
).nextFuelCode
}
])
}
}, [optionsData, existingFuelCode, isGridReady])

Expand Down
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 f1e2249

Please sign in to comment.