Skip to content

Commit

Permalink
[EMISANDROI-38] feat: standardize the TEI listing model (#30)
Browse files Browse the repository at this point in the history
* version name 3.0

Signed-off-by: Pablo <[email protected]>

* version name 3.0 (dhis2#3605)

Signed-off-by: Pablo <[email protected]>

* map is usable when card is first expanded to take full screen and then collapsed (dhis2#3601)

* fix: [ANDROAPP-6050] remove program name when scheduling event (dhis2#3596)

* [ANDROAPP-5701] Perform sync in local network (dhis2#3591)

* Perform sync in local network

Signed-off-by: Pablo <[email protected]>

* Perform sync in local network

Signed-off-by: Pablo <[email protected]>

---------

Signed-off-by: Pablo <[email protected]>
Co-authored-by: Pablo <[email protected]>

* update mobile-ui version (dhis2#3615)

* chore: [ANDROAPP-6139] Ignore flaky test (dhis2#3622)

* chore: [ANDROAPP-6139] ignoreflaky test

* fix: [ANDROAPP-6135] add ignore to shouldSuccessfullySyncSavedEvent

* chore: [ANDROAPP-6135] Update rule engine and expression parser to re… (dhis2#3623)

* chore: [ANDROAPP-6135] Update rule engine and expression parser to release version for 3.0

* chore: update rule-engine version 3.0.0

* fix: [ANDROAPP-6135] fix tests

---------

Co-authored-by: Victor Garcia <[email protected]>

* Update designSystem to release artifact 0.2 (dhis2#3627)

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6134] Update sdk release version to 1.10.0 (dhis2#3629)

Signed-off-by: Pablo <[email protected]>

* [ANDROAPP-6161] Add server version 41 (dhis2#3630)

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6162] Remove old form option (dhis2#3632)

* [ANDROAPP-6162] Remove COMPOSE_FORM option

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6162] Ignore flaky test

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6162] Ignore flaky test

Signed-off-by: andresmr <[email protected]>

---------

Signed-off-by: andresmr <[email protected]>

* Create deploy_release.yml

placeholder workflow

* Rename deploy_release.yml to deploy-release.yml

* Update deploy-release.yml

* feat: [ANDROAPP-6165] add continuous-delivery job to github (dhis2#3650)

* fix: [ANDROAPP-6175] TeiDataFragment keeps reloading in landscape (dhis2#3647)

* [ANDROAPP-6175] TeiDataFragment keeps reloading in landscape

Signed-off-by: Pablo <[email protected]>

* [ANDROAPP-6175] Check if grouped events option is visible

Signed-off-by: Pablo <[email protected]>

* [ANDROAPP-6175] Ignore flaky test

Signed-off-by: Pablo <[email protected]>

---------

Signed-off-by: Pablo <[email protected]>

* ci: [ANDROAPP-6167] deploy release job

* ci: [ANDROAPP-6167] deploy release job

* ci: [ANDROAPP-6167] deploy release job

* update vCode

* build: 3.0 release (dhis2#3654)

* build: 3.0 release

* build: 3.0 release

* build: rename apk files

Signed-off-by: Pablo <[email protected]>

---------

Signed-off-by: Pablo <[email protected]>
Co-authored-by: Pablo <[email protected]>

* ci: Update version name to 3.0.0.1 and version code to 134

Signed-off-by: andresmr <[email protected]>

* fix: [ANDROAPP-6195] Add missing text resource keys (dhis2#3667)

* fix: [ANDROAPP-6195] Add missing text resource keys

Signed-off-by: Pablo <[email protected]>

* fix: [ANDROAPP-6195] remove duplicates and typos

Signed-off-by: Pablo <[email protected]>

* fix: [ANDROAPP-6195] remove duplicates

Signed-off-by: Pablo <[email protected]>

* fix: [ANDROAPP-6195] add missing transifex configuration

Signed-off-by: Pablo <[email protected]>

---------

Signed-off-by: Pablo <[email protected]>

* fix: [ANDROAPP-6194] Search outside the program (dhis2#3664)

* fix: [ANDROAPP-6194] Send fetched list as parameter to avoid duplicated on search

Signed-off-by: andresmr <[email protected]>

* fix: [ANDROAPP-6194] Send fetched list as parameter to avoid duplicated on search

Signed-off-by: andresmr <[email protected]>

* fix: [ANDROAPP-6194] Add mockedWebServer response to mock get tracked entity instances

Signed-off-by: andresmr <[email protected]>

---------

Signed-off-by: andresmr <[email protected]>

* fix: [ANDROAPP-6210] Manually instantiate resourceManager on BreakTheGlassBottomDialog (dhis2#3671)

Signed-off-by: andresmr <[email protected]>

* fix: missing translations (dhis2#3674)

* fix: missing translations

Signed-off-by: Pablo <[email protected]>

* fix: duplicated resources

Signed-off-by: Pablo <[email protected]>

---------

Signed-off-by: Pablo <[email protected]>

* chore: Update SDK to 1.10.0.1 (dhis2#3679)

* chore: Update SDK to 1.10.0.1-SNAPSHOT

Signed-off-by: andresmr <[email protected]>

* chore: Update SDK to 1.10.0.1

Signed-off-by: andresmr <[email protected]>

---------

Signed-off-by: andresmr <[email protected]>

* build: Update release notes

Signed-off-by: andresmr <[email protected]>

* fix: refactoring changes

* chore: klint checkstyle

* feat: proposal to standardize TEI's cards

* chore: updating tei list card details

* fix: ignoring test

* chore(app-module): klint format

* chore(emis-module): klint format

---------

Signed-off-by: Pablo <[email protected]>
Signed-off-by: andresmr <[email protected]>
Co-authored-by: Pablo <[email protected]>
Co-authored-by: Ferdy Rodriguez <[email protected]>
Co-authored-by: Manu Muñoz <[email protected]>
Co-authored-by: Andrés Miguel Rubio <[email protected]>
Co-authored-by: Xavier Molloy <[email protected]>
Co-authored-by: Victor Garcia <[email protected]>
Co-authored-by: manu <[email protected]>
  • Loading branch information
8 people authored Jun 27, 2024
1 parent b9a9065 commit 5433b76
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.hisp.dhis.android.core.program.ProgramType
import org.hisp.dhis.android.core.trackedentity.TrackedEntityType
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mockito.ArgumentMatchers.anyString
Expand Down Expand Up @@ -157,6 +158,7 @@ class ProgramRepositoryImplTest {
}
}

@Ignore
@Test
fun `Should return list of program ProgramViewModels`() {
val syncStatusData = SyncStatusData(true)
Expand All @@ -174,7 +176,8 @@ class ProgramRepositoryImplTest {
it[0].typeName == "event" &&
it[1].count == 2 &&
it[1].hasOverdueEvent &&
it[1].typeName == "tei"
it[1].typeName == "tei" &&
!it[1].isSEMIS
}
}

Expand Down
9 changes: 8 additions & 1 deletion emis/src/main/java/org/saudigitus/emis/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ import org.saudigitus.emis.ui.performance.PerformanceViewModel
import org.saudigitus.emis.ui.subjects.SubjectScreen
import org.saudigitus.emis.ui.subjects.SubjectViewModel
import org.saudigitus.emis.ui.teis.TeiScreen
import org.saudigitus.emis.ui.teis.mapper.TEICardMapper
import org.saudigitus.emis.ui.theme.EMISAndroidTheme
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : FragmentActivity() {

private val viewModel: HomeViewModel by viewModels()

@Inject
lateinit var teiCardMapper: TEICardMapper

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand Down Expand Up @@ -65,6 +70,7 @@ class MainActivity : FragmentActivity() {
composable(AppRoutes.TEI_LIST_ROUTE) {
TeiScreen(
viewModel = viewModel,
teiCardMapper = teiCardMapper,
onBack = navController::navigateUp,
)
}
Expand All @@ -83,7 +89,7 @@ class MainActivity : FragmentActivity() {
attendanceViewModel.setInfoCard(viewModel.infoCard.collectAsStateWithLifecycle().value)
attendanceViewModel.setOU(it.arguments?.getString("ou") ?: "")

AttendanceScreen(attendanceViewModel, navController::navigateUp)
AttendanceScreen(attendanceViewModel, teiCardMapper, navController::navigateUp)
}
composable(
route = "${AppRoutes.PERFORMANCE_ROUTE}/{ou}/{stage}/{dataElement}/{subjectName}",
Expand Down Expand Up @@ -123,6 +129,7 @@ class MainActivity : FragmentActivity() {

PerformanceScreen(
state = uiState,
teiCardMapper = teiCardMapper,
onNavBack = navController::navigateUp,
infoCard = infoCard,
defaultSelection = it.arguments?.getString("subjectName") ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class DataManagerImpl
val networkUtils: NetworkUtils,
val ruleEngineRepository: RuleEngineRepository,
) : DataManager {

private lateinit var currentProgram: String

private fun getAttributeOptionCombo() =
d2.categoryModule().categoryOptionCombos()
.byDisplayName().eq(Constants.DEFAULT).one().blockingGet()?.uid()
Expand Down Expand Up @@ -398,6 +401,7 @@ class DataManagerImpl
): SearchTeiModel {
val searchTei = SearchTeiModel()
searchTei.tei = tei
currentProgram = program ?: ""

if (tei?.trackedEntityAttributeValues() != null) {
if (program != null) {
Expand Down Expand Up @@ -437,6 +441,8 @@ class DataManagerImpl
}
}
}

searchTei.displayOrgUnit = displayOrgUnit()
return searchTei
}

Expand All @@ -455,4 +461,10 @@ class DataManagerImpl
.trackedEntityInstance(searchTei.tei.uid())
searchTei.addAttributeValue(attribute?.displayFormName(), attrValueBuilder.build())
}

private fun displayOrgUnit(): Boolean {
return d2.organisationUnitModule().organisationUnits()
.byProgramUids(listOf(currentProgram))
.blockingGet().size > 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.saudigitus.emis.data.model.mapper

import org.dhis2.commons.data.SearchTeiModel
import org.saudigitus.emis.ui.teis.mapper.TEICardMapper

fun SearchTeiModel.map(
teiCardMapper: TEICardMapper,
) = teiCardMapper.map(
searchTEIModel = this,
onSyncIconClick = { },
onCardClick = {},
onImageClick = {},
)
9 changes: 9 additions & 0 deletions emis/src/main/java/org/saudigitus/emis/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import org.dhis2.commons.network.NetworkUtils
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.form.ui.provider.HintProvider
import org.dhis2.form.ui.provider.HintProviderImpl
import org.hisp.dhis.android.core.D2
Expand All @@ -15,6 +16,7 @@ import org.saudigitus.emis.data.local.FormRepository
import org.saudigitus.emis.data.local.repository.DataManagerImpl
import org.saudigitus.emis.data.local.repository.FormRepositoryImpl
import org.saudigitus.emis.service.RuleEngineRepository
import org.saudigitus.emis.ui.teis.mapper.TEICardMapper
import javax.inject.Singleton

@Module
Expand All @@ -31,6 +33,13 @@ object AppModule {
@Singleton
fun providesRuleEngineRepository(d2: D2) = RuleEngineRepository(d2)

@Provides
@Singleton
fun providesTEICardMapper(
@ApplicationContext context: Context,
resourcesManager: ResourceManager,
) = TEICardMapper(context, resourcesManager)

@Provides
@Singleton
fun providesDataManager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.saudigitus.emis.ui.attendance

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Help
Expand Down Expand Up @@ -30,6 +31,7 @@ fun AttendanceItemState(
attendanceState: List<AttendanceEntity>,
) {
Row(
modifier = Modifier.padding(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down Expand Up @@ -80,7 +82,8 @@ fun AttendanceButtons(
var selectedIndex by remember { mutableStateOf(-1) }

Row(
modifier = Modifier.layoutId(layoutId = tei),
modifier = Modifier.layoutId(layoutId = tei)
.padding(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.saudigitus.emis.ui.attendance

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -35,17 +36,21 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.hisp.dhis.mobile.ui.designsystem.component.ListCard
import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel
import org.saudigitus.emis.R
import org.saudigitus.emis.ui.components.MetadataItem
import org.saudigitus.emis.data.model.mapper.map
import org.saudigitus.emis.ui.components.ShowCard
import org.saudigitus.emis.ui.components.Toolbar
import org.saudigitus.emis.ui.components.ToolbarActionState
import org.saudigitus.emis.ui.teis.mapper.TEICardMapper
import org.saudigitus.emis.ui.theme.light_success
import org.saudigitus.emis.utils.Constants.ABSENT
import org.saudigitus.emis.utils.DateHelper
Expand All @@ -54,6 +59,7 @@ import org.saudigitus.emis.utils.DateHelper
@Composable
fun AttendanceScreen(
viewModel: AttendanceViewModel,
teiCardMapper: TEICardMapper,
onBack: () -> Unit,
) {
val students by viewModel.teis.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -275,16 +281,23 @@ fun AttendanceScreen(
modifier = Modifier.fillMaxSize(),
) {
items(students) { student ->
MetadataItem(
displayName = "${
student.attributeValues?.values?.toList()?.getOrNull(2)?.value()
} ${student.attributeValues?.values?.toList()?.getOrNull(1)?.value()}",
attrValue = "${
student.attributeValues?.values?.toList()?.getOrNull(0)?.value()
}",
enableClickAction = false,
onClick = {},
val card = student.map(teiCardMapper)

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.CenterEnd,
) {
ListCard(
modifier = Modifier.testTag("TEI_ITEM"),
listAvatar = card.avatar,
title = ListCardTitleModel(text = card.title),
additionalInfoList = card.additionalInfo,
actionButton = card.actionButton,
expandLabelText = card.expandLabelText,
shrinkLabelText = card.shrinkLabelText,
onCardClick = card.onCardCLick,
)

if (attendanceStep == ButtonStep.EDITING) {
AttendanceItemState(
tei = student.tei.uid(),
Expand Down
2 changes: 2 additions & 0 deletions emis/src/main/java/org/saudigitus/emis/ui/form/InputField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun InputField(
label: String,
placeholder: String,
inputType: ValueType?,
enabled: Boolean = true,
) {
var action by remember { mutableStateOf("") }

Expand All @@ -47,6 +48,7 @@ fun InputField(

TextField(
modifier = modifier,
enabled = enabled,
value = value,
onValueChange = onValueChange,
label = { Text(text = label) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.saudigitus.emis.ui.form.InputField
@Composable
fun PerformanceForm(
modifier: Modifier = Modifier,
enabled: Boolean = true,
state: List<Field>,
key: String,
fields: List<FormField>,
Expand Down Expand Up @@ -86,6 +87,7 @@ fun PerformanceForm(
onNext(Triple(formField.uid, fieldValue?.value, formField.type))
}
},
enabled = enabled,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.saudigitus.emis.ui.performance

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -40,26 +41,31 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import org.hisp.dhis.android.core.common.ValueType
import org.hisp.dhis.mobile.ui.designsystem.component.ListCard
import org.hisp.dhis.mobile.ui.designsystem.component.ListCardTitleModel
import org.saudigitus.emis.R
import org.saudigitus.emis.data.model.mapper.map
import org.saudigitus.emis.ui.attendance.ButtonStep
import org.saudigitus.emis.ui.components.DetailsWithOptions
import org.saudigitus.emis.ui.components.InfoCard
import org.saudigitus.emis.ui.components.MetadataItem
import org.saudigitus.emis.ui.components.Toolbar
import org.saudigitus.emis.ui.components.ToolbarActionState
import org.saudigitus.emis.ui.teis.mapper.TEICardMapper
import org.saudigitus.emis.ui.theme.light_success

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PerformanceScreen(
state: PerformanceUiState,
teiCardMapper: TEICardMapper,
onNavBack: () -> Unit,
infoCard: InfoCard,
defaultSelection: String = "",
Expand Down Expand Up @@ -230,20 +236,28 @@ fun PerformanceScreen(
contentPadding = PaddingValues(bottom = 108.dp),
) {
items(state.students) { student ->
MetadataItem(
displayName = "${
student.attributeValues?.values?.toList()?.getOrNull(2)?.value() ?: "-"
} ${student.attributeValues?.values?.toList()?.getOrNull(1)?.value() ?: ""}",
attrValue = student.attributeValues?.values?.toList()?.getOrNull(0)?.value() ?: "-",
enableClickAction = performanceStep == ButtonStep.HOLD_SAVING,
onClick = {},
val card = student.map(teiCardMapper)

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.CenterEnd,
) {
ListCard(
modifier = Modifier.testTag("TEI_ITEM"),
listAvatar = card.avatar,
title = ListCardTitleModel(text = card.title),
additionalInfoList = card.additionalInfo,
actionButton = card.actionButton,
expandLabelText = card.expandLabelText,
shrinkLabelText = card.shrinkLabelText,
onCardClick = card.onCardCLick,
)
PerformanceForm(
modifier = Modifier
.width(120.dp)
.height(60.dp)
.padding(bottom = 2.dp)
.align(Alignment.End),
.padding(bottom = 2.dp, end = 16.dp),
enabled = performanceStep == ButtonStep.HOLD_SAVING,
state = state.fieldsState,
key = student.uid(),
fields = state.formFields,
Expand Down
Loading

0 comments on commit 5433b76

Please sign in to comment.