Skip to content

Add custom callback for autocomplete #2764

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dilys-l
Copy link

@dilys-l dilys-l commented Jan 3, 2025

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2738

Description
Adds the ability for the client to pass a custom callback to AutoComplete for dynamic AutoComplete answer resolution

Alternative(s) considered
NA

Type
Feature

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@dilys-l dilys-l requested a review from a team as a code owner January 3, 2025 03:26
@dilys-l dilys-l requested a review from aditya-07 January 3, 2025 03:26
Copy link

google-cla bot commented Jan 3, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment on lines 50 to 58
callbacks = mapOf(Pair(CustomCallbackType.AUTO_COMPLETE, AutoCompleteCallback(
callback = { query ->
run {
listOf(AutoCompleteViewAnswerOption("a", "Type 2 Diabetes Mellitus"),
AutoCompleteViewAnswerOption("b", "Test")
)
}
}
)))
Copy link
Collaborator

@FikriMilano FikriMilano Jan 7, 2025

Choose a reason for hiding this comment

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

on line 51, other than the query, I think we also need the value set resolver url to be passed in the API.

the url will be provided by the questionnaire item, what it does that it can point to a terminology server to retrieve the option lists, then the query will filter that lists so we can have less options to process

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think what fikri meant is tha tthe url should be passed as another parameter besides the query string itself. otherwise how do we distinguish different valueset searches?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah good point. I will make this change.

Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

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

Thanks @dilys-l! A couple of questions below.

Comment on lines 50 to 58
callbacks = mapOf(Pair(CustomCallbackType.AUTO_COMPLETE, AutoCompleteCallback(
callback = { query ->
run {
listOf(AutoCompleteViewAnswerOption("a", "Type 2 Diabetes Mellitus"),
AutoCompleteViewAnswerOption("b", "Test")
)
}
}
)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think what fikri meant is tha tthe url should be passed as another parameter besides the query string itself. otherwise how do we distinguish different valueset searches?

- Combined functionality with the ExternalAnswerValueSetResolver
- Renamed various functions and arguments for improved clarity
- Moved filter handling out of the adapter and into the textChangedListener
- Moved resolver to the viewmodel
@dilys-l dilys-l force-pushed the feature/add-custom-callback-for-autocomplete branch 2 times, most recently from bdaff86 to 1adc09e Compare February 17, 2025 05:06
@dilys-l dilys-l force-pushed the feature/add-custom-callback-for-autocomplete branch from e69ecaa to 2c14713 Compare May 13, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Enhance the ExternalAnswerValueSetResolver to take a search string
3 participants