Skip to content

Commit

Permalink
[EMISANDROI-35] feat: remove mandatory filter selection for staff and…
Browse files Browse the repository at this point in the history
… displaying its own modules (#27)

* chore: setting default state for semis module in tests

* chore: update app logo

* chore: setting default state for semis module in tests

* chore: sets dhis2 methods nullable

* delete: remove FavoriteSerialization

* chore: adds json config

* chore: update app logo

* chore: update datatype to nullable

* chore: update datatype to nullable

* feat: check if select program is SEMIS

* feat: sets performance module according to selected program

* feat: checks and load teis according to semis program selection

* chore: implements color utils instance for dynamic color

* chore: implements data verification for different programs

* chore: remove unused fun

* chore: add new line to fix ktlint

* fix: ktlint format

* fix: ktlint format
  • Loading branch information
CarlosMacaneta authored Jun 10, 2024
1 parent 4f9d9d2 commit 9c90538
Show file tree
Hide file tree
Showing 95 changed files with 812 additions and 838 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.dhis2.usescases.main.program

import android.content.Context
import android.graphics.Color
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
Expand Down Expand Up @@ -99,6 +98,7 @@ class ProgramUiTest {
hasOverdueEvent = true,
false,
downloadState = ProgramDownloadState.NONE,
stockConfig = null
stockConfig = null,
isSEMIS = false
)
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
android:allowBackup="false"
android:fullBackupContent="@xml/old_backup_config"
android:dataExtractionRules="@xml/data_extraction_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/emis_logo"
android:label="@string/app_name"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/data/service/SyncPresenterImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class SyncPresenterImpl(
Completable.fromObservable(
d2.dataStoreModule()
.dataStoreDownloader()
.download()
.download(),
).doOnError {
Timber.d("error while downloading Data store")
}.onErrorComplete()
.doOnComplete { Timber.d("finished datastore download") }
.doOnComplete { Timber.d("finished datastore download") },
)
.andThen(
Completable.fromObservable(
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/login/ui/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fun LoginTopBar(
modifier = Modifier
.weight(1f)
.height(48.dp),
painter = painterResource(id = R.drawable.ic_dhis_white),
contentDescription = "dhis2 logo",
painter = painterResource(id = R.drawable.emis_logo_white),
contentDescription = "SEMIS logo",
)

if (displayMoreActions) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/dhis2/usescases/main/HomeNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sealed class HomeItemData(
override val accessDataWrite: Boolean,
val trackedEntityType: String,
val stockConfig: AppConfig?,
val isSEMIS: Boolean
val isSEMIS: Boolean,
) : HomeItemData(uid, label, accessDataWrite)

data class EventProgram(
Expand Down Expand Up @@ -94,7 +94,7 @@ fun ActivityResultLauncher<Intent>.navigateTo(context: Context, homeItemData: Ho
putExtras(ProgramEventDetailActivity.getBundle(homeItemData.uid))
launch(this)
}
}
}

is HomeItemData.TrackerProgram -> {
if (homeItemData.isSEMIS) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/dhis2/usescases/main/HomeRepositoryImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import org.hisp.dhis.android.core.category.CategoryOptionCombo
import org.hisp.dhis.android.core.program.ProgramType
import org.hisp.dhis.android.core.systeminfo.SystemInfo
import org.hisp.dhis.android.core.user.User
import org.saudigitus.emis.data.model.EMISConfig
import org.saudigitus.emis.utils.Constants

class HomeRepositoryImpl(
private val d2: D2,
Expand Down Expand Up @@ -65,6 +67,17 @@ class HomeRepositoryImpl(
return d2.programs().size + d2.dataSetInstanceSummaries().size
}

private fun isSEMIS(program: String): Boolean {
val dataStore = d2.dataStoreModule()
.dataStore()
.byNamespace().eq("semis")
.byKey().eq(Constants.KEY)
.one().blockingGet()

val config = EMISConfig.fromJson(dataStore?.value()) ?: emptyList()
return config.find { it.program == program } != null
}

override fun singleHomeItemData(): HomeItemData? {
val program = d2.programs().firstOrNull()
val dataSetInstance = d2.dataSetInstanceSummaries().firstOrNull()
Expand All @@ -81,6 +94,7 @@ class HomeRepositoryImpl(
} else {
null
},
isSEMIS = isSEMIS(program.uid()),
)

program?.programType() == ProgramType.WITHOUT_REGISTRATION ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal class ProgramRepositoryImpl(
} else {
null
},
isSEMIS = isSEMIS(program.uid())
isSEMIS = isSEMIS(program.uid()),
)
}.toList().toFlowable().blockingFirst()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ private fun testingProgramModel() = ProgramViewModel(
false,
downloadState = ProgramDownloadState.NONE,
stockConfig = null,
isSEMIS = false,
)

const val HOME_ITEMS = "HOME_ITEMS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class ProgramViewModel(
val downloadState: ProgramDownloadState,
val downloadActive: Boolean = false,
val stockConfig: AppConfig?,
val isSEMIS: Boolean
val isSEMIS: Boolean,
) {
private var hasShownCompleteSyncAnimation = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ProgramViewModelMapper() {
filtersAreActive = filtersAreActive,
downloadState = ProgramDownloadState.NONE,
stockConfig = null,
isSEMIS = false,
)
}

Expand Down Expand Up @@ -63,6 +64,7 @@ class ProgramViewModelMapper() {
filtersAreActive = filtersAreActive,
downloadState = ProgramDownloadState.NONE,
stockConfig = null,
isSEMIS = false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private fun testingProgramModel(downloadState: ProgramDownloadState) = ProgramVi
false,
downloadState = downloadState,
stockConfig = null,
isSEMIS = false,
)

const val PROGRAM_TO_ENROLL = "PROGRAM_TO_ENROLL_%s"
2 changes: 1 addition & 1 deletion emis/src/main/java/org/saudigitus/emis/AppRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ object AppRoutes {
const val ABSENTEEISM_ROUTE = "ABSENTEEISM_ROUTE"
const val PERFORMANCE_ROUTE = "PERFORMANCE_ROUTE"
const val SUBJECT_ROUTE = "SUBJECT_ROUTE"
}
}
20 changes: 10 additions & 10 deletions emis/src/main/java/org/saudigitus/emis/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ class MainActivity : FragmentActivity() {
setContent {
EMISAndroidTheme(
darkTheme = false,
dynamicColor = false
dynamicColor = false,
) {
viewModel.setBundle(intent?.extras)

val navController = rememberNavController()

Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
color = MaterialTheme.colorScheme.background,
) {
NavHost(
navController = navController,
startDestination = AppRoutes.HOME_ROUTE
startDestination = AppRoutes.HOME_ROUTE,
) {
composable(AppRoutes.HOME_ROUTE) {
HomeScreen(
viewModel = viewModel,
onBack = { finish() },
navTo = navController::navigate
navTo = navController::navigate,
)
}
composable(AppRoutes.TEI_LIST_ROUTE) {
Expand All @@ -71,8 +71,8 @@ class MainActivity : FragmentActivity() {
arguments = listOf(
navArgument("ou") {
type = NavType.StringType
}
)
},
),
) {
val attendanceViewModel: AttendanceViewModel = hiltViewModel()

Expand All @@ -98,7 +98,7 @@ class MainActivity : FragmentActivity() {
navArgument("subjectName") {
type = NavType.StringType
},
)
),
) {
val performanceViewModel = hiltViewModel<PerformanceViewModel>()
val uiState by performanceViewModel.uiState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -131,7 +131,7 @@ class MainActivity : FragmentActivity() {
onNext = performanceViewModel::onClickNext,
step = performanceViewModel::setButtonStep,
onFilterClick = performanceViewModel::updateDataFields,
onSave = performanceViewModel::save
onSave = performanceViewModel::save,
)
}
composable(
Expand All @@ -140,7 +140,7 @@ class MainActivity : FragmentActivity() {
navArgument("ou") {
type = NavType.StringType
},
)
),
) {
val subjectViewModel = hiltViewModel<SubjectViewModel>()
val state by subjectViewModel.uiState.collectAsStateWithLifecycle()
Expand All @@ -156,7 +156,7 @@ class MainActivity : FragmentActivity() {
infoCard = infoCard,
onClick = { subjectId, subjectName ->
navController.navigate("${AppRoutes.PERFORMANCE_ROUTE}/$ou/$stage/$subjectId/$subjectName")
}
},
)
}
}
Expand Down
18 changes: 9 additions & 9 deletions emis/src/main/java/org/saudigitus/emis/data/local/DataManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@ interface DataManager {
ou: String,
program: String,
programStage: String,
attendance: AttendanceEntity
attendance: AttendanceEntity,
)
suspend fun getConfig(id: String): List<EMISConfigItem>?

suspend fun getOptions(
dataElement: String
dataElement: String,
): List<DropdownItem>

suspend fun getOptionsByCode(
dataElement: String,
codes: List<String>
codes: List<String>,
): List<DropdownItem>

suspend fun getAttendanceOptions(
program: String
program: String,
): List<AttendanceOption>

suspend fun getDataElement(uid: String): DataElement
suspend fun getDataElement(uid: String): DataElement?

suspend fun getTeisBy(
ou: String,
program: String,
stage: String,
dataElementIds: List<String>,
options: List<String>
options: List<String>,
): List<SearchTeiModel>

suspend fun trackedEntityInstances(
ou: String,
program: String
program: String,
): List<SearchTeiModel>

suspend fun getAttendanceEvent(
Expand All @@ -54,12 +54,12 @@ interface DataManager {
dataElement: String,
reasonDataElement: String? = null,
teis: List<String>,
date: String?
date: String?,
): List<AttendanceEntity>

suspend fun dateValidation(id: String): CalendarConfig?

suspend fun getSubjects(stage: String): List<Subject>

suspend fun getTerms(stages: List<ProgramStage>): List<DropdownItem>
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.saudigitus.emis.data.local


import org.hisp.dhis.android.core.option.Option
import org.saudigitus.emis.data.model.EventTuple
import org.saudigitus.emis.ui.form.FormData
Expand All @@ -15,6 +14,6 @@ interface FormRepository {
program: String,
programStage: String,
dataElement: String,
teis: List<String>
teis: List<String>,
): List<FormData>
}
}
Loading

0 comments on commit 9c90538

Please sign in to comment.