ERA-12362: report-form-builder: Support OR operator for sections with multiple conditions#1586
Conversation
- Upgrade Yarn to version 4.15.0 in .yarnrc.yml and package.json. - Bump various dependencies in package.json. - Update yarn.lock to reflect the changes in dependencies.
- Introduced a comprehensive AGENTS.md file detailing core concepts, events, subjects, observations, tracks, patrols, and spatial features related to the EarthRanger platform. - Removed outdated business and development context files to streamline documentation.
- Updated the evaluateSectionConditions utility to support logical operators (AND, OR) for section conditions. - Modified the SchemaForm component to utilize the new logical operator functionality. - Added tests to verify the correct evaluation of section conditions based on the logical operators. - Introduced SECTION_ELEMENT_CONDITIONS_LOGICAL_OPERATORS constant for better maintainability.
There was a problem hiding this comment.
The Cursor rule files were deleted to not having to maintain the agents' context files two times. Now we use AGENTS.md, which is supported by Cursor.
| import evaluateIsNotContainedByCondition from './evaluateIsNotContainedByCondition'; | ||
| import evaluateIsNotEmptyCondition from './evaluateIsNotEmptyCondition'; | ||
| import { FORM_ELEMENT_LOGIC_CONDITION_OPERATORS } from '../../../../../utils/v2-event-schemas/constants'; | ||
| import { |
There was a problem hiding this comment.
Update the conditional section evaluations to show / hide the sections in the UI so now they use the conditions logical operator (AND vs OR).
| // it is the root JSON schema. | ||
| const sectionJSONSubschema = | ||
| uiSchema.sections[sectionId].conditions?.length > 0 | ||
| const conditionalSectionJSONSubschema = |
There was a problem hiding this comment.
Very similar to the change made in https://github.com/PADAS/report-form-builder/pull/270.
When transforming the section schema, now we read the schema combinator (anyOf vs allOf) to derive the conditions logical operator.
| @@ -0,0 +1,295 @@ | |||
| # AGENTS.md | |||
There was a problem hiding this comment.
Our new context files, using the standardizes AGENTS.md.
There was a problem hiding this comment.
And a symlink from CLAUDE.md to AGENTS.md.
There was a problem hiding this comment.
Pull request overview
Adds support for a conditions logical operator on conditional sections (AND/OR) in the v2 SchemaForm pipeline, deriving OR from JSON Schema if.anyOf and updating section visibility evaluation accordingly. Also includes dependency/Yarn upgrades and consolidates Cursor rules into AGENTS.md.
Changes:
- Add
SECTION_ELEMENT_CONDITIONS_LOGICAL_OPERATORSconstant and persistconditionsLogicalOperatoronto section form elements during schema → formElements transformation. - Update
evaluateSectionConditions+ SchemaForm section filtering to support AND/OR semantics; expand unit tests to cover OR and short-circuit behavior. - Upgrade dependencies/Yarn and replace
.cursor/rules/*docs withAGENTS.md(plus related doc setup).
Reviewed changes
Copilot reviewed 14 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/v2-event-schemas/constants.js | Introduces section conditions logical operator constants. |
| src/utils/v2-event-schemas/transformSchemaToFormElements/transformSection/index.js | Sets conditionsLogicalOperator on section form elements (OR when if.anyOf is used). |
| src/utils/v2-event-schemas/transformSchemaToFormElements/transformSection/index.test.js | Updates/extends transformSection tests to assert logical operator behavior. |
| src/ReportManager/DetailsSection/SchemaForm/utils/evaluateSectionConditions/index.js | Implements AND/OR evaluation logic for section conditions. |
| src/ReportManager/DetailsSection/SchemaForm/utils/evaluateSectionConditions/index.test.js | Adds coverage for AND/OR and invalid-operator behavior. |
| src/ReportManager/DetailsSection/SchemaForm/index.js | Passes conditionsLogicalOperator into section-visibility evaluation. |
| package.json | Dependency upgrades + Yarn version bump. |
| mock-api/package.json | Minor dependency upgrade. |
| .yarnrc.yml | Updates Yarn release path to 4.15.0. |
| AGENTS.md | New consolidated rules/context document. |
| .cursor/rules/business.mdc | Removed (content moved to AGENTS.md). |
| .cursor/rules/development.mdc | Removed (content moved to AGENTS.md). |
| .cursor/rules/testing.mdc | Removed (content moved to AGENTS.md). |
Comments suppressed due to low confidence (1)
src/ReportManager/DetailsSection/SchemaForm/utils/evaluateSectionConditions/index.test.js:305
- This test currently asserts that an invalid
conditionsLogicalOperatorreturnstrueand does not evaluate any conditions. If the implementation defaults invalid/missing operators to AND (to preserve backwards compatibility and avoid unintentionally showing conditional sections), update the test expectation to match that behavior.
test('passes the evaluation of a section if the conditions logical operator is not valid', () => {
expect(evaluateSectionConditions(sectionConditions, 'INVALID_LOGICAL_OPERATOR', formData)).toBe(true);
expect(evaluateContainsCondition).not.toHaveBeenCalled();
expect(evaluateIsContainedByCondition).not.toHaveBeenCalled();
expect(evaluateIsEmptyCondition).not.toHaveBeenCalled();
expect(evaluateIsExactlyCondition).not.toHaveBeenCalled();
expect(evaluateIsNotContainedByCondition).not.toHaveBeenCalled();
expect(evaluateIsNotEmptyCondition).not.toHaveBeenCalled();
});
…ical operator - Updated the evaluateSectionConditions utility to return false instead of true when an invalid logical operator is provided. - Adjusted the corresponding test to reflect this change, ensuring accurate evaluation of section conditions. - Clarified comments in the transformSection utility regarding logical operators.
What does this PR do?
Add support for "conditions logical operator" in conditional sections. Specifically add support for an OR operator.
This PR also:
Evidence
Relevant link(s)