Skip to content

Commit

Permalink
Merge branch 'release/2.10' into ANDROAPP-6081
Browse files Browse the repository at this point in the history
  • Loading branch information
andresmr authored Apr 25, 2024
2 parents f3dd3f5 + bf3c686 commit 549026c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.dhis2.usescases.searchTrackEntity.listView.SearchResult
import org.dhis2.usescases.searchTrackEntity.searchparameters.model.SearchParametersUiState
import org.dhis2.usescases.searchTrackEntity.ui.UnableToSearchOutsideData
import org.dhis2.utils.customviews.navigationbar.NavigationPageConfigurator
import org.hisp.dhis.android.core.arch.helpers.Result
import org.hisp.dhis.android.core.common.ValueType
import org.hisp.dhis.android.core.maintenance.D2ErrorCode
import timber.log.Timber
Expand Down Expand Up @@ -809,13 +810,25 @@ class SearchTEIViewModel(
}

is FormIntent.OnFocus -> {
val updatedItems = uiState.items.map {
if (it.focused && it.uid != formIntent.uid) {
(it as FieldUiModelImpl).copy(focused = false)
} else if (it.uid == formIntent.uid) {
(it as FieldUiModelImpl).copy(focused = true)
val updatedItems = uiState.items.map { field ->
if (field.focused && field.uid != formIntent.uid) {
val validation = field.value?.takeIf {
field.valueType in listOf(
ValueType.DATE, ValueType.DATETIME, ValueType.AGE, ValueType.TIME,
)
}?.let { value -> field.valueType?.validator?.validate(value) }

(field as FieldUiModelImpl).copy(
focused = false,
error = when (validation) {
is Result.Failure -> resourceManager.getString(R.string.formatting_error)
else -> null
},
)
} else if (field.uid == formIntent.uid) {
(field as FieldUiModelImpl).copy(focused = true)
} else {
it
field
}
}
uiState = uiState.copy(items = updatedItems)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ class FilterManagerTest {
eventStatusList = listOf(),
eventDateList = listOf("date"),
assignedToMe = listOf(),
filters = mapOf(),
stageUid = "stageUid",
dataValues = mapOf(),
)
filterManager.setWorkingListScope(workingListScope)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ data class TeiWorkingListScope(
val eventStatusList: List<String>?,
val eventDateList: List<String>?,
val assignedToMe: List<AssignedUserMode>?,
val filters: Map<String, String>?,
val stageUid: String?,
val dataValues: Map<String, String>?,
) : WorkingListScope() {
override fun isAssignedActive(): Boolean = assignedToMe?.isNotEmpty() == true
override fun isAssignedToMeActive(): Boolean =
Expand Down Expand Up @@ -109,6 +112,9 @@ fun TrackedEntityInstanceQueryRepositoryScope.mapToWorkingListScope(
eventFilters().mapNotNull { it.eventDate() }
.mapNotNull { resources.dateFilterPeriodToText(it) },
eventFilters().mapNotNull { it.assignedUserMode() }.distinct(),
filter().associateBy({ it.key() }, { it.value() }),
programStage(),
dataValue().associateBy({ it.key() }, { it.value() }),
)
}

Expand Down

0 comments on commit 549026c

Please sign in to comment.