Skip to content

ERA-12362: report-form-builder: Support OR operator for sections with multiple conditions#1586

Open
luixlive wants to merge 7 commits into
developfrom
ERA-12362
Open

ERA-12362: report-form-builder: Support OR operator for sections with multiple conditions#1586
luixlive wants to merge 7 commits into
developfrom
ERA-12362

Conversation

@luixlive
Copy link
Copy Markdown
Contributor

@luixlive luixlive commented Jun 1, 2026

What does this PR do?

Add support for "conditions logical operator" in conditional sections. Specifically add support for an OR operator.

This PR also:

  • Upgrades dependencies.
  • Move Cursor rule files to an AGENTS.md.
  • Add a CLAUDE.md with a symlink to AGENTS.md.

Evidence

Relevant link(s)

luixlive added 6 commits May 29, 2026 13:14
- 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.
Comment thread .cursor/rules/business.mdc Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 =
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread AGENTS.md
@@ -0,0 +1,295 @@
# AGENTS.md
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our new context files, using the standardizes AGENTS.md.

Comment thread CLAUDE.md
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a symlink from CLAUDE.md to AGENTS.md.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_OPERATORS constant and persist conditionsLogicalOperator onto 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 with AGENTS.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 conditionsLogicalOperator returns true and 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants