Skip to content

Commit

Permalink
Merge pull request #2728 from bcgov/464-uat-form-errors
Browse files Browse the repository at this point in the history
464 uat form errors
  • Loading branch information
gdalcengio authored Feb 3, 2025
2 parents 5fe0dce + 592f5ba commit f6685c3
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"annualFuelAmount": {
"title": "Annual Fuel Amount",
"type": "number",
"minimum": 0
"minimum": 0,
"readOnly": true,
"default": 0
},
"emissions": {
"title": "Emission Data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
}
}
},
"fuelDescription": {
"title": "Fuel Description",
"maxLength": 500,
"type": "string"
},
"annualFuelAmount": {
"title": "Annual Fuel Amount",
"type": "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
}
}
},
"fuelDescription": {
"title": "Fuel Description",
"maxLength": 500,
"type": "string"
},
"annualFuelAmount": {
"title": "Annual Fuel Amount",
"type": "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
}
}
},
"fuelDescription": {
"title": "Fuel Description",
"maxLength": 500,
"type": "string"
},
"annualFuelAmount": {
"title": "Annual Fuel Amount",
"type": "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
}
}
},
"fuelDescription": {
"title": "Fuel Description",
"maxLength": 500,
"type": "string"
},
"annualFuelAmount": {
"title": "Annual Fuel Amount",
"type": "number",
Expand Down
161 changes: 161 additions & 0 deletions bc_obps/reporting/migrations/0049_alter_gcs_add_CEMS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Generated by Django 5.0.6 on 2024-07-10 20:27

from django.db import migrations

#### CONFIG DATA ####


def add_configuration_element_data(apps, schema_monitor):
'''
Add additional data to erc.configuration_element
'''

ConfigurationElement = apps.get_model('reporting', 'ConfigurationElement')
Activity = apps.get_model('registration', 'Activity')
SourceType = apps.get_model('reporting', 'SourceType')
GasType = apps.get_model('reporting', 'GasType')
Methodology = apps.get_model('reporting', 'Methodology')
Configuration = apps.get_model('reporting', 'Configuration')
ConfigurationElement.objects.bulk_create(
[
# General stationary combustion excluding line tracing
# CO2 - with production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(name='General stationary combustion excluding line tracing').id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste with production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - without production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(name='General stationary combustion excluding line tracing').id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of waste without production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# General stationary combustion solely for the purpose of line tracing
# CO2 - with production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary combustion solely for the purpose of line tracing'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste with production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - without production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary combustion solely for the purpose of line tracing'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of waste without production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# General stationary combustion, other than non-compression and non-processing combustion
# CO2 - with production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary combustion, other than non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste at a linear facilities operation resulting in the production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - without production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary combustion, other than non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste at a linear facilities operation not resulting in the production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - Field gas or process vent gas combustion at a linear facilities operation
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary combustion, other than non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='Field gas or process vent gas combustion at a linear facilities operation'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# General stationary non-compression and non-processing combustion
# CO2 - with production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste at a linear facilities operation resulting in the production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - without production of useful energy
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='General stationary combustion of fuel or waste at a linear facilities operation not resulting in the production of useful energy'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
# CO2 - Field gas or process vent gas combustion at a linear facilities operation
ConfigurationElement(
activity_id=Activity.objects.get(
name='General stationary non-compression and non-processing combustion'
).id,
source_type_id=SourceType.objects.get(
name='Field gas or process vent gas combustion at a linear facilities operation'
).id,
gas_type_id=GasType.objects.get(chemical_formula='CO2').id,
methodology_id=Methodology.objects.get(name='CEMS').id,
valid_from_id=Configuration.objects.get(valid_from='2023-01-01').id,
valid_to_id=Configuration.objects.get(valid_to='2099-12-31').id,
),
]
)


class Migration(migrations.Migration):

dependencies = [('reporting', '0048_remove_activitysourcetypejsonschema_invalid_if_has_unit_and_no_fuel')]

operations = [
migrations.RunPython(add_configuration_element_data),
]
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def testDataExists(self):
'Measured Steam/Default EF': 3,
'Measured CC': 1,
'Measured Steam/Measured EF': 2,
'CEMS': 0,
'Alternative Parameter Measurement': 1,
'Replacement Methodology': 1,
},
Expand Down Expand Up @@ -79,4 +80,4 @@ def testDataExists(self):
msg=f'{source_type_name}:{gas_name} contains config for the proper methods and field counts',
)

assert len(config_elements) == 48
assert len(config_elements) == 50
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def testDataExists(self):
'Measured Steam/Default EF': 3,
'Measured CC': 1,
'Measured Steam/Measured EF': 2,
'CEMS': 0,
'Alternative Parameter Measurement': 1,
'Replacement Methodology': 1,
},
Expand Down Expand Up @@ -80,4 +81,4 @@ def testDataExists(self):
msg=f'{source_type_name}:{gas_name} contains config for the proper methods and field counts',
)

assert len(config_elements) == 72
assert len(config_elements) == 75
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def testDataExists(self):
'Measured Steam/Default EF': 3,
'Measured CC': 1,
'Measured Steam/Measured EF': 2,
'CEMS': 0,
'Alternative Parameter Measurement': 1,
'Replacement Methodology': 1,
},
Expand Down Expand Up @@ -82,4 +83,4 @@ def testDataExists(self):
msg=f'{source_type_name}:{gas_name} contains config for the proper methods and field counts',
)

assert len(config_elements) == 72
assert len(config_elements) == 75
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def testDataExists(self):
'Measured Steam/Default EF': 3,
'Measured CC': 1,
'Measured Steam/Measured EF': 2,
'CEMS': 0,
'Alternative Parameter Measurement': 1,
'Replacement Methodology': 1,
},
Expand Down Expand Up @@ -79,4 +80,4 @@ def testDataExists(self):
msg=f'{source_type_name}:{gas_name} contains config for the proper methods and field counts',
)

assert len(config_elements) == 48
assert len(config_elements) == 50
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { multiStepHeaderSteps } from "@reporting/src/app/components/taskList/mul
import { customizeValidator } from "@rjsf/validator-ajv8";
import setNestedErrorForCustomValidate from "@bciers/utils/src/setCustomValidateErrors";
import { findPathsWithNegativeNumbers } from "@bciers/utils/src/findInObject";
import { calculateMobileAnnualAmount } from "@bciers/utils/src/customReportingActivityFormCalculations";

const CUSTOM_FIELDS = {
fuelType: (props: FieldProps) => <FuelFields {...props} />,
Expand Down Expand Up @@ -74,6 +75,7 @@ export default function ActivityForm({
}, [currentActivity]);

const customValidate = (formData: { [key: string]: any }, errors: any) => {
// Negative numbers
const results = findPathsWithNegativeNumbers(formData);
results.forEach((result) => {
setNestedErrorForCustomValidate(errors, result, "must be >= 0");
Expand Down Expand Up @@ -106,6 +108,10 @@ export default function ActivityForm({
setSelectedSourceTypeIds(selectedSourceTypes);
}

// Add together quarterly amounts for Fuel Combustion by Mobile Equipment
if (c.formData?.sourceTypes?.mobileFuelCombustionPartOfFacility)
calculateMobileAnnualAmount(c.formData);

setFormState(c.formData);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ const uiSchema = {
title: "Fuel",
},
items: {
"ui:order": ["fuelType", "annualFuelAmount", "emissions"],
"ui:order": [
"fuelType",
"fuelDescription",
"annualFuelAmount",
"emissions",
],
fuelType: {
"ui:field": "fuelType",
"ui:FieldTemplate": FieldTemplate,
Expand All @@ -76,6 +81,9 @@ const uiSchema = {
"ui:FieldTemplate": InlineFieldTemplate,
},
},
fuelDescription: {
"ui:FieldTemplate": InlineFieldTemplate,
},
annualFuelAmount: {
"ui:FieldTemplate": InlineFieldTemplate,
},
Expand Down Expand Up @@ -138,7 +146,12 @@ const uiSchema = {
title: "Fuel",
},
items: {
"ui:order": ["fuelType", "annualFuelAmount", "emissions"],
"ui:order": [
"fuelType",
"fuelDescription",
"annualFuelAmount",
"emissions",
],
fuelType: {
"ui:field": "fuelType",
"ui:FieldTemplate": FieldTemplate,
Expand All @@ -155,6 +168,9 @@ const uiSchema = {
"ui:FieldTemplate": InlineFieldTemplate,
},
},
fuelDescription: {
"ui:FieldTemplate": InlineFieldTemplate,
},
annualFuelAmount: {
"ui:FieldTemplate": InlineFieldTemplate,
},
Expand Down
7 changes: 7 additions & 0 deletions bciers/libs/styles/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ input::-webkit-inner-spin-button {
input[type="number"] {
-moz-appearance: textfield;
}

/* Purely so that scrolling doesn't increment/decrement value in rjsf number fields */
.rjsf input[type="number"] {
-webkit-appearance: none; /* Disable native browser scroll */
appearance: none;
pointer-events: none; /* Disable scrolling */
}
Loading

0 comments on commit f6685c3

Please sign in to comment.