From 31993efd0977fdad0fa9a3abaf533f29010a2f2c Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Fri, 27 Aug 2021 14:58:09 -0700 Subject: [PATCH] [Hacky] Fix nested repeats with relevance This is a targeted fix for one user, addressing a case where relevance on a nested/grouped repeat only works for the first top-level repeat. It causes a test failure for another use case, which provides helpful testing context and sort of hints at a likely direction for a more general fix. --- src/js/relevant.js | 5 +- .../forms/core-804-nested-repeat-relevant.xml | 158 ++++++++++++++++++ 2 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 test/forms/core-804-nested-repeat-relevant.xml diff --git a/src/js/relevant.js b/src/js/relevant.js index 971d9ceb2..58aece651 100644 --- a/src/js/relevant.js +++ b/src/js/relevant.js @@ -87,8 +87,9 @@ export default { * but currently has 0 repeats, the context will not be available. This same logic is applied in output.js. */ let context = p.path; - if ( getChild( node, `.or-repeat-info[data-name="${p.path}"]` ) && !getChild( node, `.or-repeat[name="${p.path}"]` ) ) { - context = null; + const repeatInfo = getChild( node, `.or-repeat-info[data-name="${p.path}"]` ); + if ( repeatInfo != null && !getChild( node, `.or-repeat[name="${p.path}"]` ) ) { + this.form.repeats.add( repeatInfo ); } /* diff --git a/test/forms/core-804-nested-repeat-relevant.xml b/test/forms/core-804-nested-repeat-relevant.xml new file mode 100644 index 000000000..f022b6c64 --- /dev/null +++ b/test/forms/core-804-nested-repeat-relevant.xml @@ -0,0 +1,158 @@ + + + + enketo-repeat-bug + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + no + + + + + + + + yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + yes + + + no + + + + + + + + yes + + + no + + + + + + + + drawing_set + + + maintenance_schedule + + + other + + + + If no file available, go to next question to take a photo + + + + + + + + yes + + + no + + + + + + If available + + + conductivity + + + flow + + + other + + + + + + + + + +