Skip to content
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

Add ability to sort items on a Spinner widget #2405

Closed
f-odhiambo opened this issue Jan 9, 2024 · 5 comments
Closed

Add ability to sort items on a Spinner widget #2405

f-odhiambo opened this issue Jan 9, 2024 · 5 comments
Labels

Comments

@f-odhiambo
Copy link
Collaborator

f-odhiambo commented Jan 9, 2024

Use case:

The spinner widget picks the data from the database and then filters it into the dropdown items (in our case locations) using fhir-path expression - Dynamic answerExpression. The implementation for this was done here #2052. POst QA we have a requirement to view the listed items in an alphabetical order (a-z)/asc/desc or by ID

Requirement
Add the ability to sort items on a Spinner widget based on defined criteria

Sample Screenshots




@pld
Copy link
Collaborator

pld commented Jan 9, 2024

How are these being sorted for display now? If it's by an internal ID, is there a way we can control that for now (e.g. based on creation order) that can serve as a temporary work around?

@brandyodhiambo
Copy link

So the sorting ability should be added here on the file DropDownViewHolderFactory
on this answerOptionList

  val answerOptionList =
          this.questionnaireViewItem.enabledAnswerOptions
            .map {
              DropDownAnswerOption(
                it.value.identifierString(context),
                it.value.displayString(context),
                it.itemAnswerOptionImage(context),
              )
            }
            .toMutableList()
        answerOptionList.add(
          0,
          DropDownAnswerOption(
            context.getString(R.string.hyphen),
            context.getString(R.string.hyphen),
            null,
          ),
        )

@jingtang10
Copy link
Collaborator

Closing with the same rationale as #2410. @f-odhiambo if you still need this please reopen and add rationale.

@github-project-automation github-project-automation bot moved this from New to Complete in Android FHIR SDK Feb 26, 2024
@jingtang10
Copy link
Collaborator

@f-odhiambo @pld just for your context - I commented in the other issue that sorting is not a behaviour well defined in the spec. I think we should respect whatever order that is provide after answer options have been resolved. we can however, define a custom extension and publish it if it's indeed what we need. please feel free to reopen if that's what you want to do.

@jingtang10
Copy link
Collaborator

How are these being sorted for display now? If it's by an internal ID, is there a way we can control that for now (e.g. based on creation order) that can serve as a temporary work around?

sorry missed this - we don't change the order at all, so if the locations are in a value set this would just be the order of the values in the valueset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

5 participants