-
Notifications
You must be signed in to change notification settings - Fork 31
Case Management #1192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Case Management #1192
Conversation
Conflicts:
- tests/main.js
added `import('tests/caseManagement'),`
- tests/options.js
included changes from various commits that added caseManagement options:
- "Check for reserved case properties" commit:a0d6a1bce25c4a064b5ecc7f2937a7b517e02e65
- "Changed submission to use case diffs" commit:646310f0e0c9ca8d5f83728482df08ea991de52c
- "Display informational message for a question with multiple case properties" commit:bd9ecf60db4ee6273b02b73c1d17939b37b01d76
- "Skeleton case management plugin" commit:e66e688de38a654d83926ff134bebe7e46c63c46
- tests/utils.js
included changes from "Add reset option for loadXML in tests" commit:053fc600a77b870dd15460983dc8996c9ef87439
It is only used by tests/utils.js
Fixes TypeError: Cannot read properties of undefined (reading 'createPatch')
Broken in "standardized this.data.caseManagement access"
commit:60822f646a01c23c7d31226a8a11bb644a203045
Bug revealed by test:
1) Vellum core
save conflict resolution logic
should not send sha1 checksum with full form post:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at _instance.onFormSave (webpack-internal:///./src/caseManagement.js:577:38)
at _instance.<computed> [as onFormSave] (webpack-internal:///./src/base.js:60:29)
at Object.success (webpack-internal:///./src/core.js:2378:23)
at Object.options.success (webpack-internal:///./lib/SaveButton.js:67:29)
at Object.ajax (webpack-internal:///./lib/SaveButton.js:83:29)
at _instance.fn.send (webpack-internal:///./src/core.js:2347:35)
at Context.eval (webpack-internal:///./tests/core.js:625:20)
It is optionally enabled by HQ, depending on the state of the associated feature flag. Previously the plugin had an inconsistently applied internal isActive flag and did not use the enabling capability of the plugin system. The flag has been removed since it is no longer needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a Case Management plugin to Vellum that provides an easy-to-use interface for saving form questions to case properties. The functionality is disabled by default and gated behind the FORMBUILDER_SAVE_TO_CASE feature flag. It combines two previously developed PRs (#1179 and #1181) with master, adds comprehensive test coverage, and makes the plugin optional.
Changes:
- Adds new
caseManagementplugin with UI for mapping questions to case properties - Introduces diff-based saving mechanism for case property mappings to enable conflict resolution
- Implements jQuery cleanup infrastructure for proper widget teardown (select2)
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/caseManagement.js | Core plugin implementation with mapping management, validation, and UI widgets |
| src/caseDiff.js | Diff calculation logic for comparing baseline and incoming case mappings |
| src/jqueryCleanup.js | jQuery cleanup hook to enable proper widget teardown |
| src/core.js | Extension points for additional parsing, XML generation, and data augmentation |
| src/form.js | Updates to createXML and handleMugRename to return values needed by plugins |
| src/parser.js | Parser support for plugin-specific XML parsing via performAdditionalParsing |
| src/writer.js | Writer support for plugin-contributed XML via contributeToAdditionalXML |
| src/widgets.js | Widget enhancements: postRender hook, configurable placeholder, custom option naming |
| src/mugs.js | Message handling improvements to support markdown in validation messages |
| src/ignoreButRetain.js | Updated to return rename updates for plugin consumption |
| src/main.js | Module loader updated to include new plugin modules |
| src/xml.js | Documentation improvement for parseXML function |
| tests/caseManagement.js | Comprehensive test suite (511 lines) covering all plugin functionality |
| tests/utils.js | Test utility updates: import cleanup, loadXML reset parameter |
| tests/options.js | Test configuration for caseManagement plugin |
| tests/main.js | Test loader updated to include caseManagement tests |
| tests/static/caseManagement/*.xml | Test fixtures for various mapping scenarios |
| package.json | Dependency updates: select2 added, jsdiff moved to devDependencies |
| yarn.lock | Lock file update for select2 |
| index.html | HTML updates to include select2 CSS and JS |
| tests/lib/hqstyle-core.css | Custom CSS for select2 widget styling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The hard-coded value was specific to a different widget (androidIntentAppId), but this function is also being reused for the case property dropdown.
MartinRiese
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will continue with e66e688 next time
MartinRiese
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Through Matts commits again.
tests/caseManagement.js
Outdated
| } | ||
|
|
||
| function getCaseManagementSection() { | ||
| const propertiesPane = $(".fd-content-right"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fd-content-right seems a bit brittle. I would expect some id query. But I see it is used a bunch in Vellum already. So it might be fine.
Product Description
This adds a Case Management section to the form builder that gives users an easy way to save questions to case properties. It is intended to be an easy-accessible, but limited form of the Case Management tab of the HQ app builder.
Technical Summary
This combines #1179 with #1181 plus merges master, fixes tests, and makes the new
caseManagementplugin optional. dimagi/commcare-hq#37298 added code to conditionally enable the feature only when the associated feature flag is enabled.Feature Flag
All user-facing changes in this PR are gated by
FORMBUILDER_SAVE_TO_CASE.Safety Assurance
Safety story
All user-facing changes are part of the
caseManagementplugin, which is disabled by default.Automated test coverage
Yes.
QA Plan
TBD
Rollback instructions