Skip to content

fix(#640): correctly nest contact group when init has nested groups#814

Open
Hendrixx-RE wants to merge 1 commit into
medic:mainfrom
Hendrixx-RE:fix(#640)-fix-for-contact-form-with-nested-groups-in-init-group
Open

fix(#640): correctly nest contact group when init has nested groups#814
Hendrixx-RE wants to merge 1 commit into
medic:mainfrom
Hendrixx-RE:fix(#640)-fix-for-contact-form-with-nested-groups-in-init-group

Conversation

@Hendrixx-RE
Copy link
Copy Markdown
Contributor

Description

fixed a bug in the contact form conversion logic that was causing /data/contact groups to be nested incorrectly when the form had other nested groups.

fixes #640

Replaced the Regular Expression based nesting logic in src/fn/convert-contact-forms.js with a DOM-based approach using DOMParser.

  1. Imports: Added DOMParser and XMLSerializer from the @xmldom/xmldom package.
  2. Logic: Instead of using a string-based search-and-replace, the code now:
    • Parses the form XML into a searchable document tree.
    • Explicitly finds the group nodes with ref="/data/contact" and ref="/data/init".
    • Moves the contact group to be a direct child at the end of the init group.

Code review items

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or integration tests where appropriate
  • Backwards compatible: Works with existing data and configuration. Any breaking changes documented in the release notes.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@Hendrixx-RE Hendrixx-RE force-pushed the fix(#640)-fix-for-contact-form-with-nested-groups-in-init-group branch from f6fbe13 to 3b898ae Compare May 1, 2026 18:24
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.

convert-contact-form can break contact form with nested groups in init group

1 participant