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

[ANDROAPP-5645] Close enrollment data section if already completed #3484

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.dhis2.data.forms.dataentry.ValueStore
import org.dhis2.data.forms.dataentry.ValueStoreImpl
import org.dhis2.form.data.EnrollmentRepository
import org.dhis2.form.data.RulesRepository
import org.dhis2.form.data.metadata.EnrollmentConfiguration
import org.dhis2.form.data.metadata.FileResourceConfiguration
import org.dhis2.form.data.metadata.OptionSetConfiguration
import org.dhis2.form.data.metadata.OrgUnitConfiguration
Expand Down Expand Up @@ -90,8 +91,7 @@ class EnrollmentModule(
): EnrollmentRepository {
return EnrollmentRepository(
fieldFactory = modelFactory,
enrollmentUid = enrollmentUid,
d2 = d2,
conf = EnrollmentConfiguration(d2, enrollmentUid),
enrollmentMode = EnrollmentMode.valueOf(enrollmentMode.name),
enrollmentFormLabelsProvider = enrollmentFormLabelsProvider,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package org.dhis2.form.data

import org.dhis2.commons.bindings.disableCollapsableSectionsInProgram
import org.dhis2.form.data.metadata.FormBaseConfiguration
import org.dhis2.form.model.FieldUiModel
import org.dhis2.form.model.SectionUiModelImpl
import org.dhis2.form.ui.FieldViewModelFactory
import org.hisp.dhis.android.core.D2
import org.hisp.dhis.android.core.imports.TrackerImportConflict
import org.hisp.dhis.android.core.program.SectionRenderingType

abstract class DataEntryBaseRepository(
private val d2: D2,
private val conf: FormBaseConfiguration,
private val fieldFactory: FieldViewModelFactory,
) : DataEntryRepository {

abstract val programUid: String?
override fun firstSectionToOpen(): String? {
return sectionUids().blockingFirst().firstOrNull()
}

override fun updateSection(
sectionToUpdate: FieldUiModel,
Expand Down Expand Up @@ -64,10 +66,7 @@ abstract class DataEntryBaseRepository(
private fun optionsFromGroups(optionGroupUids: List<String>): List<String> {
if (optionGroupUids.isEmpty()) return emptyList()
val optionsFromGroups = arrayListOf<String>()
val optionGroups = d2.optionModule().optionGroups()
.withOptions()
.byUid().`in`(optionGroupUids)
.blockingGet()
val optionGroups = conf.optionGroups(optionGroupUids)
for (optionGroup in optionGroups) {
for (option in optionGroup.options()!!) {
if (!optionsFromGroups.contains(option.uid())) {
Expand Down Expand Up @@ -106,6 +105,6 @@ abstract class DataEntryBaseRepository(
}

override fun disableCollapsableSections(): Boolean? {
return programUid?.let { d2.disableCollapsableSectionsInProgram(programUid = it) }
return programUid?.let { conf.disableCollapsableSectionsInProgram(programUid = it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.dhis2.form.model.FieldUiModel

interface DataEntryRepository {
fun list(): Flowable<List<FieldUiModel>>
fun firstSectionToOpen(): String?
fun sectionUids(): Flowable<List<String>>
fun updateSection(
sectionToUpdate: FieldUiModel,
Expand Down
Loading
Loading