File tree Expand file tree Collapse file tree 2 files changed +38
-8
lines changed
form/src/main/java/org/dhis2/form/data Expand file tree Collapse file tree 2 files changed +38
-8
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class FormRepositoryImpl(
48
48
private var runDataIntegrity: Boolean = false
49
49
private var calculationLoop: Int = 0
50
50
private var backupList: List <FieldUiModel > = emptyList()
51
+ private val fieldsWithOptionEffects = mutableListOf<FieldUiModel >()
51
52
52
53
private val disableCollapsableSections: Boolean? =
53
54
dataEntryRepository.disableCollapsableSections()
@@ -522,9 +523,22 @@ class FormRepositoryImpl(
522
523
}
523
524
}
524
525
526
+ fieldsWithOptionEffects.forEach { field ->
527
+ field.optionSet?.let { optionSetUid ->
528
+ fetchOptions(field.uid, optionSetUid)
529
+ }
530
+ }
531
+
532
+ fieldsWithOptionEffects.clear()
533
+
525
534
ruleEffectsResult?.fieldsWithOptionEffects()?.forEach { fieldWithOptionEffect ->
526
- itemList.find { it.uid == fieldWithOptionEffect }?.let {
527
- it.optionSet?.let { optionSetUid -> fetchOptions(it.uid, optionSetUid) }
535
+ val item = itemList.find { it.uid == fieldWithOptionEffect }
536
+
537
+ item?.let { field ->
538
+ field.optionSet?.let { optionSetUid ->
539
+ fetchOptions(field.uid, optionSetUid)
540
+ }
541
+ fieldsWithOptionEffects.add(field)
528
542
}
529
543
}
530
544
Original file line number Diff line number Diff line change @@ -41,12 +41,28 @@ open class FormBaseConfiguration(private val d2: D2) {
41
41
.getPagingData(10 )
42
42
}.map { pagingData ->
43
43
pagingData.filter { option ->
44
- ! optionsToHide.contains(option.uid()) &&
45
- ! optionGroupsToHide.contains(option.uid()) &&
46
- (
47
- optionGroupsToShow.isEmpty() ||
48
- optionGroupsToShow.contains(option.uid())
49
- )
44
+
45
+ val optionInGroupToHide = d2.optionModule().optionGroups()
46
+ .withOptions()
47
+ .byUid().`in `(optionGroupsToHide)
48
+ .blockingGet().find { optionGroup ->
49
+ optionGroup.options()?.map { it.uid() }?.contains(option.uid()) == true
50
+ } != null
51
+
52
+ val optionInGroupToShow = d2.optionModule().optionGroups()
53
+ .withOptions()
54
+ .byUid().`in `(optionGroupsToShow)
55
+ .blockingGet().find { optionGroup ->
56
+ optionGroup.options()?.map { it.uid() }?.contains(option.uid()) == true
57
+ } != null
58
+
59
+ val hideOption = if (optionGroupsToShow.isEmpty()) {
60
+ optionsToHide.contains(option.uid()) || optionInGroupToHide
61
+ } else {
62
+ ! optionInGroupToShow
63
+ }
64
+
65
+ ! hideOption
50
66
}
51
67
}
52
68
}
You can’t perform that action at this time.
0 commit comments