-
Notifications
You must be signed in to change notification settings - Fork 303
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 Choice widget #801
Open Choice widget #801
Conversation
4063d8f
to
9bcb787
Compare
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.
This is exemplary work. Thanks @kevinmost!
One design decision in the single select case: Should "Other" and the edit text box be on the same line? I think there might be space concern.. but if they're not on the same line, do we want to hide the edit text until other is selected? Can we get some UX input?
In the multi select case - do we even need to have an "other" checkbox? Can we just not have it?
Alternatively, we can have an edit text with an "add option" button which if you click will convert what's in the edit text to a checkbox that is automatically ticked (and can't be unticked, but can be removed)...
...apture/src/main/java/com/google/android/fhir/datacapture/views/OptionSelectDialogFragment.kt
Show resolved
Hide resolved
...apture/src/main/java/com/google/android/fhir/datacapture/views/OptionSelectDialogFragment.kt
Show resolved
Hide resolved
...apture/src/main/java/com/google/android/fhir/datacapture/views/OptionSelectDialogFragment.kt
Outdated
Show resolved
Hide resolved
...apture/src/main/java/com/google/android/fhir/datacapture/views/OptionSelectDialogFragment.kt
Outdated
Show resolved
Hide resolved
...apture/src/main/java/com/google/android/fhir/datacapture/views/OptionSelectDialogFragment.kt
Show resolved
Hide resolved
UX perspective
|
Thanks @shelaghm! I don't really think the "other" check box does much in the multi select case. Can the user untick the box and will the user input options still be there but just not selected as answers (discarded when you submit the questionnaire)? my proposal is have all the given options, and have a button that says add other, which will create a new edit text with a remove button next to it. and you can click the button again to add another row. these rows will be automatically selected. so the pattern is very similar to what's in the existing implementation, just without the other checkbox, and with the edit text and the add button always visible. another possible design is we don't even have an add button... whenever you start typing in an edit text, another row will be created. this feels super slick :) To me, in the multi select case at least, the presence of the user input indicates the custom options should be selected. to remove them that's what the remove button is for. |
re 4 i like "-" because it's simple and clear. the trash icon looks very busy and seems highly contextual... (maybe to some people trash cans don't look exactly like that?) |
Thanks for elaborating. I hear you on that it seems more clear to use the remove '-' button than to uncheck the other box if you want to unselect/remove the other choice. The 'add other' button could also help with people typing in the text, rather than just selecting other without adding the descriptive text. I mocked up what it could look like with an 'add other' button and without "other" listed in the list of options and I think the pattern works. see below Is there a scenario where we want to enable selecting other, but not adding edit text? |
9bcb787
to
daf2736
Compare
I made #816 to track Shelagh's UX suggestions; I fully agree with these changes but feel like we should do them in a follow-up PR. PTAL @jingtang10, thanks! |
Codecov Report
@@ Coverage Diff @@
## master #801 +/- ##
============================================
- Coverage 36.19% 35.08% -1.11%
+ Complexity 269 238 -31
============================================
Files 117 111 -6
Lines 4045 3181 -864
Branches 664 562 -102
============================================
- Hits 1464 1116 -348
+ Misses 2260 1821 -439
+ Partials 321 244 -77 Continue to review full report at Codecov.
|
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.
Thanks @kevinmost :)
val otherOptionsAllowed: Boolean, | ||
) | ||
|
||
private val viewModel: QuestionnaireItemDialogSelectViewModel by activityViewModels() |
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.
@kevinmost @jingtang10
Is the reason we instantiated QuestionnaireItemDialogSelectViewModel
using activityViewModels()
because it is also shared by QuestionnaireItemDialogSelectViewHolderFactory.kt
? The only drawback I see is that even though the QuestionnaireFragment (which is used to render the QuestionnaireViewItem
) is not alive, the model is kept in memory, which raises issue #2055
Approach 1 to fix the issue :
private fun selectedOptionsFlow(linkId: String) = linkIdsToSelectedOptionsFlow.getOrPut(linkId) { MutableSharedFlow(replay = 1) }
Is it okay to change the replay count to 0? If the replay count is set to 0, I do not see the issue existing. The selected option is also stored as an answer, so if the same view is rendered, it can be shown as selected.
requireNotNull(holder.question.context.tryUnwrapContext()) { | ||
"Can only use dialog select in an AppCompatActivity context" | ||
} | ||
val viewModel: QuestionnaireItemDialogSelectViewModel by activity.viewModels() |
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.
please refer earlier comment.
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #689
Description
This PR refactors out
OptionSelectDialogFragment
from the previousMultiSelectDialogFragment
.OptionSelectDialogFragment
now supports all permutations of the following options:addOtherOptions
: If this is true, the dialog will append an additional option called "Other". When this option is selected, ifmultiSelectEnabled = false
, the user will see a single EditText in which they can enter a free-form option. IfmultiSelectEnabled = true
, the user will see an "Add another answer" button. When clicked, this button will show additional EditTexts (which will have delete buttons next to them).multiSelectEnabled
: This is controlled by therepeats
option on a questionnaire item. This decides whether checkboxes or radio buttons are used, and affects the behavior ofaddOtherOptions
as detailed above.This PR also modifies the behavior of
"type": "choice"
UX elements when anitemControl
is not explicitly specified. Questions with 10+ answers are now presented in a dialog.Alternative(s) considered
Discussed offline. This approach gives us the most flexibility and conforms best to FHIR data standards.
Type
Choose one: (Feature)
Screenshots (if applicable)
Single-select:
Multi-select:
Questionnaire Response
Note that
valueCoding
is used for pre-defined answers, whilevalueString
is used for custom answers:Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project./gradlew check
and./gradlew connectedCheck
to test my changes locally