-
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
Show repeat in hierarchy view even if first instance has no relevant content #4762
Conversation
Once again test_app seems not to like me for no obvious reason. |
Definitely awaiting review, does this reopen it? (Seems not) |
@dimwight I've reopened and marked ready for review. When something is ready, you can just hit the "Ready for review" button above the test/quality checks, so we know you're not still working on it. |
Doesn't seem to appear for me, maybe because of failed check which I can't see how to resolve. Oops, seem to have closed it again. :( |
Blocking this on making sure we fully understand the issue (I don't). |
Would it help if I spelled out in detail what I think is going on? (I certainly had some difficulty getting my head round it.) |
Yes that'd be great! Happy to dive in, but if you've already got a good idea of what's happening, it'd be great to hear. |
Hi @seadowg, an overview as promised of the issue and my proposed resolution. In
Before proceeding either way,
Issue #4570 arises from the corner case of A where repeats derive from a multiple select. Even if the first repeat is empty, some of those following will not be - the group should definitely be displayed. For this PR the existing logic is refined such that the first repeat is never skipped even when empty, so its group is always displayed. The unlikely case that all repeats in a group are empty simply results in a harmless (and maybe expressive) empty picker. |
I've also updated the PR as follows.
|
What do you mean by "empty" here? No relevant questions?
This is the part I'm having trouble understanding. Why does the example form in #4570 (and in this PR) cause that issue? I'm probably missing something obvious, but I couldn't see why selecting 'beans' would result in different behaviour from selecting other vegetables. Is there maybe a simpler/smaller form that could illustrate the problem? |
Hi @seadowg, I'm sorry you're finding this issue hard to disentangle, it's trivial on the face of it but quite subtle. With a bit of luck you'll find my latest commit of some help. In essence it recapitulates my own investigations and proposed fix, by adding to The four members of Flag
|
And to explicitly answer your other questions as well:
Beans is special because it's the first item in the veg_type choices; if it's not selected the first repeat is empty. And it's the first repeat that triggers the Frequencies repeat header in the hierarchy view: under the existing logic it doesn't if empty and therefore non-relevant (hence the issue), with my fix it always does. Finally
I do think this is the minimal form to demonstrate the issue. |
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.
As per our discussion on Slack, next steps are:
- Remove the
SCENARIO_4570
debug code - Use the simpler form (posted in the issue) for the test rather than the veg form
Done in 'Removed debug code'
Done in 'Updated test with simpler form'. Also checked that the test fails appropriately when in
|
And then test_app failed code that passed when previously committed! |
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 again for wrapping your head around this and then explaining it to me. There are a couple of tweaks I'd like to see, and I've also thought about a slightly different implementation that'd be good to discuss.
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
@@ -30,6 +30,7 @@ | |||
.around(new CopyFormRule("formHierarchy2.xml", null)) | |||
.around(new CopyFormRule("formHierarchy3.xml", null)) | |||
.around(new CopyFormRule("repeat_group_new.xml", null)) | |||
.around(new CopyFormRule("Empty First Repeat.xml", null)) |
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.
Just a note to myself to rework this test file to remove CopyFormRule
before merging this. I won't make you slog through that @dimwight.
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.
Probably a good thing as my code here is pure copy and paste, I've no idea as to how it works.
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
@dimwight is this ready for another review? You can request that with the 🔃 icon next to my name in "Reviewers". |
} | ||
|
||
@Test | ||
public void empty_first_repeat() { |
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.
I don't think we need both tests now. As far as I can see showRepeatsPickerWhenFirstRepeatIsEmpty()
enforces the correct code on its own.
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.
Definitely, I only put the earlier one back as a check.
collect_app/src/main/java/org/odk/collect/android/activities/FormHierarchyActivity.java
Outdated
Show resolved
Hide resolved
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.
I'm going to do a little work to rewrite a test file here in a newer style, but this is ready for QA I think! I think testing repeats in general, especially with relevance would be good in addition to testing the issue at hand.
Excellent, thanks @seadowg for your help! |
Tested with success! Verified cases:
|
Successfully tested on Android versions: 8.1, 9.0, 10.0 |
Closes #4570
Blocked on #4570 discussionWhat has been done to verify that this works as intended?
Tested manually and with new test added to
FormHierarchyTest
(empty_first_repeat
is a placeholder name, help needed for a suitable final one).Why is this the best possible solution? Were any other approaches considered?
Trivial fix to ensure that
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?
Shows no regression when tested before and after with
testDebug
andconnectedDebugAndroidTest
.Do we need any specific form for testing your changes? If so, please attach one.
The issue contains example forms.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No, behaviour is now as expected.
Before 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.