-
Notifications
You must be signed in to change notification settings - Fork 128
task: [ANDROAPP-7449] Add InputCustomIntent to TrackerInputProvider #4602
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: feature/tracker-search-refactor
Are you sure you want to change the base?
Conversation
...c/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt
Outdated
Show resolved
Hide resolved
form/src/main/java/org/dhis2/form/ui/provider/inputfield/CustomIntentProvider.kt
Outdated
Show resolved
Hide resolved
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 pull request adds support for custom intent input fields to the TrackerInputProvider, enabling custom intent functionality in search parameter screens. The implementation follows the existing pattern from the form module and integrates custom intent handling into the tracker-based search flow.
Changes:
- Implemented InputCustomIntent component in TrackerInputProvider for handling custom intent fields
- Added new UI event (OnLaunchCustomIntent) and input type (CUSTOM_INTENT) to support custom intents
- Integrated custom intent launching and result handling in SearchTEIViewModel and SearchParametersScreen
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/provider/TrackerInputProvider.kt | Added CUSTOM_INTENT case with InputCustomIntent component and state management |
| tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputUiEvent.kt | Added OnLaunchCustomIntent event for triggering custom intent actions |
| tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputType.kt | Added CUSTOM_INTENT enum value |
| tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputModel.kt | Added customIntentUid field to support custom intent identification |
| tracker/src/commonMain/composeResources/values/strings.xml | Added "custom_intent_launch" string resource |
| tracker/src/commonMain/composeResources/values-zh/strings.xml | Added Chinese translation for custom intent launch button |
| tracker/src/commonMain/composeResources/values-cs/strings.xml | Added Czech translation for custom intent launch button |
| form/src/main/java/org/dhis2/form/ui/provider/inputfield/FieldProvider.kt | Removed unused resources parameter |
| form/src/main/java/org/dhis2/form/ui/provider/inputfield/CustomIntentProvider.kt | Migrated from ResourceManager to stringResource for compose resources |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/mapper/ParameterInputModelMapper.kt | Updated mapper to handle custom intent fields and map to CUSTOM_INTENT type |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt | Added custom intent launcher, result handling, and event dispatching |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt | Added onLaunchCustomIntent and handleCustomIntentResult methods |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchRepositoryKt.kt | Added getCustomIntent interface method |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchRepositoryImplKt.kt | Implemented getCustomIntent method delegating to customIntentRepository |
| app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchAction.kt | Created new sealed interface for search actions including LaunchCustomIntent |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
form/src/main/java/org/dhis2/form/ui/provider/inputfield/CustomIntentProvider.kt
Outdated
Show resolved
Hide resolved
| ) | ||
| } |
Copilot
AI
Jan 21, 2026
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.
The customIntentState is not being updated when the result is received. Unlike the form module's CustomIntentProvider which handles CustomIntentResult callbacks and updates the state accordingly, this implementation only sets the state to LOADING when launching the intent but never updates it back to LAUNCH or LOADED based on success or error.
When the result is processed in SearchTEIViewModel.handleCustomIntentResult, it updates the input value and error but has no way to reset the customIntentState in the TrackerInputProvider. This means the button will remain in a loading state indefinitely even after the custom intent completes.
Consider adding a mechanism to propagate the result state back to the UI component, similar to how the form module tracks isLoadingData in the FieldUiModel and uses it in getCustomIntentState.
app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt
Show resolved
Hide resolved
| fun handleCustomIntentResult(customIntentResult: CustomIntentResult) { | ||
| when (customIntentResult) { | ||
| is CustomIntentResult.Error -> { | ||
| updateSearchParameters( | ||
| customIntentResult.fieldUid, | ||
| null, | ||
| resourceManager.getString(R.string.custom_intent_error), | ||
| ) | ||
| } | ||
|
|
||
| is CustomIntentResult.Success -> { | ||
| updateSearchParameters( | ||
| customIntentResult.fieldUid, | ||
| listOf(customIntentResult.value), | ||
| ) | ||
| } | ||
| } | ||
| } |
Copilot
AI
Jan 21, 2026
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.
The new method handleCustomIntentResult lacks test coverage. Given that SearchTEIViewModel has comprehensive existing test coverage in SearchTEIViewModelTest.kt, this method should have tests to verify both success and error paths, including:
- Successful custom intent result updates the search parameters with the returned value
- Error result updates the search parameters with the error message and clears the value
| override suspend fun getCustomIntent(fieldUid: FieldUid) = | ||
| withContext(dispatcher.io()) { | ||
| customIntentRepository.getCustomIntent( | ||
| triggerUid = fieldUid, | ||
| orgUnitUid = null, | ||
| actionType = CustomIntentActionTypeModel.SEARCH, | ||
| ) | ||
| } |
Copilot
AI
Jan 21, 2026
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.
The new method getCustomIntent lacks test coverage. Given that SearchRepositoryImplKt has existing test coverage in SearchRepositoryTest.kt, this method should be tested to verify it correctly delegates to customIntentRepository.getCustomIntent with the appropriate parameters (triggerUid, orgUnitUid as null, and actionType as SEARCH).
| ) | ||
| } |
Copilot
AI
Jan 21, 2026
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.
The customIntentState uses remember(inputModel) but this won't recalculate the state when inputModel.value changes, since remember only re-executes when the key instance changes, not when properties change. This means:
- When onClear is called and inputModel.onValueChange(null) is invoked, the customIntentState will remain as LOADED instead of reverting to LAUNCH
- When a value is successfully loaded after being empty, the state won't automatically update from LAUNCH to LOADED
Compare this to the form module's CustomIntentProvider which uses remember(values, fieldUiModel) and has the values as a separate state that can trigger recomposition.
Consider using derivedStateOf or adding inputModel.value as a remember key: remember(inputModel, inputModel.value).
5660492 to
e43d1ea
Compare
e43d1ea to
3100f7d
Compare
|




Description
Link the JIRA issue.
Please provide a clear definition of the problem and explain your solution.