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

Menu buttons for FormHierarchy #2763

Merged
merged 23 commits into from
Jan 23, 2019
Merged

Conversation

cooperka
Copy link
Contributor

@cooperka cooperka commented Dec 17, 2018

Implements menu buttons discussed in getodk/roadmap#19

  • Add repeat child (visible on the "repeat picker" screen)
  • Delete repeat child (visible when viewing a repeat child)
  • Go up (visible on any screen other than the beginning)

screenshot with add, up

screenshot with delete, up

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

  • "Go up" button displays on the first screen in some forms
  • Deleting the last indexed (bottom) item in a repeat group causes a jump all the way to the first page in some forms
  • Repeats with jr:count shouldn't have buttons to add/delete
  • Deleting the last remaining item in a repeat group causes a navigation into the preceding repeat group, if there are 2 in a row, rather than navigating "up" in the hierarchy

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@yanokwa yanokwa added this to the v1.19 milestone Jan 8, 2019
Copy link
Contributor

@zestyping zestyping left a 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();
Copy link
Contributor

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!

Copy link
Contributor Author

@cooperka cooperka Jan 9, 2019

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.

String name = formController.getLastRepeatedGroupName();
int repeatcount = formController.getLastRepeatedGroupRepeatCount();
if (repeatcount != -1) {
name += " (" + (repeatcount + 1) + ")";
Copy link
Contributor

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)"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Friends (2):

screenshot from 2019-01-09 12-32-21

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.

@cooperka cooperka mentioned this pull request Jan 9, 2019
3 tasks
@cooperka
Copy link
Contributor Author

@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.

@mmarciniak90
Copy link
Contributor

@cooperka I noticed that buttons are not visible in the view g1 (1) but are visible for view g1 (2) in the form fewRepeatGroups.xml.txt

screenshot_20190115-110903 screenshot_20190115-110907

Similar situation for form:
nested-indexed-repeat.xml.txt

screenshot_20190115-111908 screenshot_20190115-111912

@cooperka please take look on this
@opendatakit-bot unlabel "needs testing"

@cooperka
Copy link
Contributor Author

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"

@zestyping
Copy link
Contributor

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.

@mmarciniak90
Copy link
Contributor

@cooperka
I checked form: nested-indexed-repeat.xml.txt

  • If user does not add any repeat group, Go Up button is visible and disappears when is clicked

  • If repeat group is added but user opens jump screen from question outside the repeat group, Go Up button is visible and disappears when is clicked

  • The same situation is for nested-repeats-complex form.

@opendatakit-bot unlabel "needs testing"

@grzesiek2010
Copy link
Member

@cooperka once you fix the bug pointed out by @mmarciniak90 please fix conflicts as well.

@cooperka cooperka force-pushed the form-hierarchy-buttons branch 2 times, most recently from 56ce3fb to ab6f02e Compare January 22, 2019 04:35
@cooperka
Copy link
Contributor Author

@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:

Top-level
  Sub-group
    Friends
      A
      B
    Enemies
      C

When viewing Enemies > C -> Click delete -> Sends you to Friends > B when it should have sent you to Sub-group.

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"

@kkrawczyk123
Copy link
Contributor

@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:
ezgif com-video-to-gif 2
(yes I clicked on + button on the last displayed screen as it is nearly visible on the gif xd )

@opendatakit-bot unlabel "needs testing"

@cooperka
Copy link
Contributor Author

cooperka commented Jan 22, 2019

I've fixed the crash itself but this case will need to be handled differently. Repeats with jr:count shouldn't have buttons to add/delete.

@grzesiek2010 do you know how we might determine if a repeat has an explicit count? I tried using getCaptionPrompt().getFormElement().getAdditionalAttribute("jr", "count") (and variations) but it always returns null... I'll post in Slack.

@cooperka
Copy link
Contributor Author

@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"

@cooperka cooperka force-pushed the form-hierarchy-buttons branch 2 times, most recently from b3d1fa4 to 1e8ec72 Compare January 22, 2019 23:04
@kkrawczyk123
Copy link
Contributor

@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

@grzesiek2010
Copy link
Member

I agree. The delete option is redundant in case of repeat groups with repeat-count number but adding new groups should be possible since we can do that on the form level.

@cooperka
Copy link
Contributor Author

I don't follow -- if, in the nested-indexed-repeat form, friend A has declared they have exactly 2 pets, are you suggesting you should be able to add a third? This seems to be disallowed, how are you able to do so? This is what I see when I'm in the form:

  1. How many pets does A have?
    1. Answer 2
    2. Swipe to next question
  2. What is pet updating autoplay to play select choices. adding text highlighting #1's name?
    1. Swipe to next question
  3. What is pet Feature/google sheets #2's name?
    1. Swipe to next question
  4. Add another "" group? [friend, not pet]

You can not add new pets, so I hid the "add" button for pets. There's still an "add" button for friends.

@grzesiek2010
Copy link
Member

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.

@grzesiek2010
Copy link
Member

@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.
@cooperka cooperka force-pushed the form-hierarchy-buttons branch from 1e8ec72 to 2182652 Compare January 23, 2019 16:33
@cooperka
Copy link
Contributor Author

@grzesiek2010 rebased and ready 👍

@yanokwa yanokwa merged commit e74548b into getodk:master Jan 23, 2019
@cooperka cooperka deleted the form-hierarchy-buttons branch January 23, 2019 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants