-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Menu buttons for FormHierarchy #2763
Conversation
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.
Hi—I have a few questions about this. Some of it is due to not having a deep understanding of how repeat groups are structured and how the FormController navigates around the form—sorry!—though I think it wouldn't hurt to spell this out a little more in comments, to help others who aren't intimately familiar with this avoid breaking it by accident; the logic looks quite intricate. I hope my comments are helpful!
In the first screenshot you posted, the individual repeated instances are shown as "Alice (1)" and "Bob (2)", and in the second, the repeated group title is "Friends (1)". Which bits of code are responsible for formatting these labels? I think these labels are a bit confusing as is (see also my comments on #2762). In particular, since "Alice (1)" and "Friends (1)" look so alike, the label doesn't make it clear whether the name identifies a repeat group title or an instance of a repeated group; I think the label should use distinct formatting to make this obvious.
If we feel good about going with my suggestion in #2762, these labels should be formatted similarly, e.g. "1. Alice", "2. Bob", and "Friends > 1".
@@ -212,8 +212,14 @@ private void updateOptionsMenu() { | |||
// Not ready yet. Menu will be updated automatically once it's been prepared. | |||
if (optionsMenu == null) return; | |||
|
|||
FormController formController = Collect.getInstance().getFormController(); | |||
boolean isAtBeginning = formController.isCurrentQuestionFirstInForm() && !shouldShowRepeatGroupPicker(); |
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.
What's the condition that this is trying to express? I'm puzzled that this is defined with the exclusion !shouldShowRepeatGroupPicker()
and then is only used once below, in an expression that then includes shouldShowPicker
, making said exclusion moot.
Are you intending for the Up button to be visible only for the second and subsequent repeated items in a repeat group? If so, why?
I might have misunderstood how isCurrentQuestionFirstInForm()
works for repeat groups, so maybe it would help if you describe the intended condition in prose first, thanks!
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 logic here is cleaned up quite a bit after the commit you're commenting on, and the latest code hopefully makes more sense.
In short, you're only at the top/beginning of the hierarchy if you're both at the first question and not showing the repeat picker. The "up" button should be displayed on every screen of the hierarchy except at the beginning, because then there's nothing to go "up" to.
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/utilities/DialogUtils.java
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
String name = formController.getLastRepeatedGroupName(); | ||
int repeatcount = formController.getLastRepeatedGroupRepeatCount(); | ||
if (repeatcount != -1) { | ||
name += " (" + (repeatcount + 1) + ")"; |
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.
In the example where the repeat section is "Friends" and each instance of the repeated group is a friend, what does this show? Suppose there are a total of three friends (Alice, Bob, Charlie) and the currently shown friend is Bob. Will it show "Friends (3)" because there are three friends, or "Friends (2)" because Bob is #2, or "Bob (2)"?
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.
Friends (2):
But this is old logic, and I think it should be improved as you described in #2762 (comment). There are probably numerous other places in the code where this type of string is built... we shoud do a quick audit if we want to update it.
@zestyping I believe I've addressed all comments now. I pushed 4 new commits at d73ad5b, and I'm now rebasing on master since it's been a while. |
d73ad5b
to
94fe7fd
Compare
@cooperka I noticed that buttons are not visible in the view Similar situation for form: @cooperka please take look on this |
Thanks for the info @mmarciniak90 -- I fixed it. Previously it would think it was at the very beginning when it was at the first question inside of the first group. @opendatakit-bot label "needs testing" |
Thanks so much for all the responses and making these edits, @cooperka! I'm sorry I didn't respond right away—I've just discovered that my Github notifications are misconfigured, so I'm fixing that and intend to be more responsive in the future. |
@cooperka
@opendatakit-bot unlabel "needs testing" |
@cooperka once you fix the bug pointed out by @mmarciniak90 please fix conflicts as well. |
56ce3fb
to
ab6f02e
Compare
@mmarciniak90 that bug should be resolved now. And @grzesiek2010 it's been rebased. There are a lot of tricky edge cases here; I tested in as many forms as I could think of and it seems to finally be working well. One remaining issue is that if there are 2 repeat groups in a row, and you delete the last remaining item from the second repeat, it will send you to the last index of the first repeat instead of going back a level as expected, i.e. if the structure is:
When viewing This is a narrow edge case, and it's not even that much of a usability issue, but @grzesiek2010 I'd appreciate your help addressing this if you think this is a blocker to merge. @opendatakit-bot label "needs testing" |
@cooperka, It looks like issues pointed by @mmarciniak90 have been fixed which is great! I have used the same forms as she did and I have noticed a crash when I tried to add a new nested group from the hierarchy view when used nested-indexed-repeat.xml form. I am attaching gif to help you with reproducing: @opendatakit-bot unlabel "needs testing" |
I've fixed the crash itself but this case will need to be handled differently. Repeats with
|
@kkrawczyk123 forms that use specific numbers of repeat items are now supported. The add/delete buttons should not be visible in these types of repeat groups. Can you please check again? @opendatakit-bot label "needs testing" |
b3d1fa4
to
1e8ec72
Compare
@cooperka I am not sure if I fully understand the approach that you followed. I can see some sense in disabling deleting within the nested group when we are giving the number of the repeats by ourselves according to getodk/javarosa#61 but if it's about adding the new items of the nested group I think that should be allowed and I don't understand why you disabled it. I am able to add the group when I am back to the form anyway. cc @yanokwa @grzesiek2010 |
I agree. The delete option is redundant in case of repeat groups with |
I don't follow -- if, in the
You can not add new pets, so I hid the "add" button for pets. There's still an "add" button for friends. |
Ahhh sorry I misunderstood if we use repeat-count we can add more groups only editing that value there is no prompt to add a new group at the end so the approach is ok @kkrawczyk123 please continue testing. |
@cooperka please resolve conflicts |
It's confusing to show it then
For consistency with the 'jump' button in FormEntry.
Avoid setting it to null, simplify logic.
Previously would think it was at the beginning when it was at the first question inside of the first group.
Otherwise the index could be changed when you visit a question then go back to the hierarchy, showing the arrow on the first screen when it shouldn't.
Previously, deleting the last indexed item in the list (i.e. bottom one of multiple) wouldn't trigger the repeat picker on some forms. But now the last remaining item (i.e. only one left) will leave the user on a blank screen. To be fixed next.
Now that it's possible to see the repeat picker in this state, due to the last commit.
1e8ec72
to
2182652
Compare
@grzesiek2010 rebased and ready 👍 |
Implements menu buttons discussed in getodk/roadmap#19
Add/delete functionality already existed (swipe forward to add; long-press on question text to delete) -- this change just makes it more accessible.
What has been done to verify that this works as intended?
Extensive manual testing with nested-repeats-complex (XML / XLS) (top-level "friends" and "enemies" groups; nested "friends/pets" group).
Navigating in and out of nested repeat groups, adding children, deleting children, editing names, using the back button, jumping back and forth between the FormEditor and FormHierarchy views.
Why is this the best possible solution? Were any other approaches considered?
Adding these buttons to the menu in FormHierarchy seems to make the most sense because that's where you get an overview of the form. FormHierarchy allows you to view children of repeat groups, and now on the same screen you can add new children. You can also delete the child currently being viewed.
Other approaches could involve showing menus elsewhere in the app, such as FormEntry, but that seems less intuitive.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
The ability to add/delete repeat instances is now easier and more obvious. The new menu buttons should make repeat group navigation more efficient. Users may not expect to see the new buttons, but no old behavior has been changed.
The behavior changes should be isolated to FormHierarchyActivity, but this activity interacts with the global state via FormController, so regressions can be avoided by ensuring that the state is not mutated in some new unexpected way.
Do we need any specific form for testing your changes? If so, please attach one.
Linked above.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Not that I can find. This page has screenshots of FormHierarchy but no repeat groups; the new buttons would not be visible in any of the screenshots.
Known issues being addressed
jr:count
shouldn't have buttons to add/deleteBefore submitting this PR, please make sure you have:
./gradlew checkAll
and confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTest
locally.