bcgov / cas-reporting

This is for the Clean Growth Digital Services team for work related to reporting.
Apache License 2.0
0 stars 0 forks source link

Methodology data should not be flat with emission data in the report activity json schema #353

Closed pbastia closed 2 weeks ago

pbastia commented 1 month ago

Description:

As a developer, I want methodology data to be inside its own object instead of flat with the emission data, so that querying is easier. This means

The result we want can likely be achieved by doing the following:

When instantiating the methodology property in the handle_gas_types() function, the methodology enum field should be encased in an rjsf object.

This has added a layer of {methodology: properties {...}} to our schema structure, so in handle_methodologies() we will have to traverse to that level in json tree to add the methodology enum & dependencies.

Adding an object to the rjsf schema will automatically add a title to the object, which we don't want (the methodology fields should still look flat to the emission fields on the form). This means we'll have to update all the rjsf ui schemas to tell them to hide the label by adding the methodology object to the ui schemas & adding the ui:option "label": false.

RJSF Docs: Objects: https://rjsf-team.github.io/react-jsonschema-form/docs/json-schema/objects/ Dependencies: https://rjsf-team.github.io/react-jsonschema-form/docs/json-schema/dependencies/

Note: I see that the json schema for carbonates_use has a methodology object defined in the json schema. This has been fine because it was being overwritten by the form_builder_service, but now that we're changing where those fields live, it might cause issues. The methodology property should be removed from this json schema & allow the form_builder_service to create it dynamically.

Acceptance Criteria:

Given a schema returned by the form_builder_service When I traverse the json tree Then the methodology data fields are contained in a methodology object rather than flat with the emission data

Development Checklist:

Definition of Ready (Note: If any of these points are not applicable, mark N/A)

Definition of Done (Note: If any of these points are not applicable, mark N/A)

Notes:

-

pbastia commented 1 month ago

@dleard 👀

patriciarussellCAS commented 1 month ago

Tagging @pbastia for further refinement :)