Skip to content

Add boolean field support#38

Open
doneill wants to merge 6 commits intodevelopfrom
36-boolean-feilds-dev
Open

Add boolean field support#38
doneill wants to merge 6 commits intodevelopfrom
36-boolean-feilds-dev

Conversation

@doneill
Copy link
Collaborator

@doneill doneill commented Mar 10, 2026

Adds support for #36

Proposed Changes

types.ts

  • V2BaseProperty.type
    • added boolean to the union
  • V2UIField.type
    • added BOOLEAN to the union

generateUISchema.ts

  • Added BOOLEAN to supportedFieldTypes in the validator so boolean fields aren't rejected

utils.ts

  • Added case BOOLEAN to createControl's switch
    • sets format: boolean so JSONForms renders it as a toggle/checkbox; description and label are handled by the existing generic logic below the switch

v2.test.ts

  • Added a BOOLEAN field type describe block with three tests: control output shape, description forwarding, and
    deprecated field suppression

Implementation Test

In React Native client app, e.g. EarthRanger

- yarn remove @earthranger/react-native-jsonforms-formatter
- yarn add @earthranger/react-native-jsonforms-formatter@2.0.0-beta.25

Unit Tests

jest test/v2.test.ts
 PASS  test/v2.test.ts
  V2 generateUISchema
    ✓ should generate UI schema for basic V2 schema (2 ms)
    ✓ should create controls with proper scopes and labels
    ✓ should handle text field options correctly
    ✓ should handle numeric field options correctly (1 ms)
    ✓ should handle choice list field options correctly
    ✓ should handle date-time field options correctly
    ✓ should handle location field options correctly
    ✓ should handle collection field options correctly
    ✓ should exclude deprecated fields
    ✓ should handle inactive sections
    ✓ should respect section order
    ✓ should handle collection constraints and column layout
    ✓ should handle single column sections correctly
    ✓ should handle two column sections correctly (React Native single-column) (1 ms)
    ✓ should apply UI field properties to collection item fields (3 ms)
    ✓ should support nested collections (collection within collection)
  BOOLEAN field type
    ✓ generates a Control with boolean format
    ✓ includes the description in options
    ✓ deprecated boolean field is not rendered

Test Suites: 1 passed, 1 total
Tests:       19 passed, 19 total
Snapshots:   0 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants