Skip to content

Commit

Permalink
[EMISANDROI-32] feat: implement program rule actions (#28)
Browse files Browse the repository at this point in the history
* importing emis module (#1)

* Create the main filter (Academic Year, School, Grade and Class) (#2)

* implementing app di

* implementing app business logic

* update

* implementing app components and theme colors

* implementing json datastore model

* implementing sdk extensions, json mapper and util constants

* implementing json model mapper and main config item

* implementing tei screen

* implementing components

* res update

* implementing filter model and state

* implementing ui bridge(students list, filter management) and data render

* update

* sending program settings to emis module

* removing verbose code and implementing filter data render

* implementing students list business logic

* implementing empty list message for non selected filters and no data found (#3)

* uniforming the app font and fixing the topbar subtitle text (#4)

* Emisandroi 2 - Resume component (#5)

* add resume component

* set the params

* fix icon and font

* fix card background

* improve the code of the Card

* Emisandroi 6 (#6)

* implementing FAB visibility according to filter selection

* implementing FAB to open attendance module

* [EMISANDROI-7] View attendance status for a specific date (#7)

* res update

* app utilities and date helper

* ignoring unknown or not mapped attrs from json datastore

* compose utilities

* implementing attendance business logic with sdk

* implementing and improving app components

* implementing app routing and sharing common data

* implementing attendance ui business logic

* download datastore on sync view

* improving card info data rendering

* [EMISANDROI-10] Update attendance status (#8)

* update(renaming classes and function to suggestive names)

* update

* ordering option as ASC

* improving metadata components

* renamed filter class

* implementing attendance data save

* implementing attendance ui business logic data

* preserving attendance data on edit and refreshing values on save

* adding success icon

* improving snackbar success message and performing refresh data on btn save click

* [EMISANDROI-12] Common fixies (#9)

* improving app dialogs and implementing first selection for academic year and datastore config update

* retrieving default value

* [EMISANDROI-13] Implement dynamic config load for different programs (#10)

* updating app logo

* json datastore update

* app name update

* app name update

* adding logo

* app logo update

* implementing data element data loaging

* implementing datastore config data loading

* checking program type by uid to select app flow

* creating dropdown state and improving filter state data loading

* extension update

* Emisandroi 9 (#11) -  Favorite Screen

* add filter view to App

* favorites models config

* implementing datastore, ktx-collection-immutable libs

* serializing favorites models

* favorites list ui data render

* implementing favorite data persistence

* add click state

* implement store favorite

* initializing model props

* file format and sending ou uid on data collect

* improving favorite data collect and saving method

* add labels to strings.xml and populate the resumeCard

* fix clear list after save

* fix selected not selected button

* fix multiple grades to school and rename files to favorites

* fix list sort and grade/class mandatory

* remove unnecessary code

* fix list size error

* check if the GRADE and SECTIon lists are empty

---------

Co-authored-by: Carlos Macaneta <[email protected]>

* Emisandroi 14 - pre-polulate the filter with favorite (#12)

* get filter from favorite in teis screen and add grade code to model

* set the school on start

* fixing static section dropdown options (#13)

* [EMISNADROI-17] School calendar implementation (#14)

* school calendar models

* implementing date validation based on school calendar

* [EMISANDROI-19] Fixing on select attendance status, null and indexoutofbounds exceptions (#15)

* fixing indexoutofbounds

* fixing indexoutofbounds and attendace status to lowercase

* set attendance status in lowercase

* implementing attendance summary ignoring string case

* handling exception and null safety

* [EMISANDROI-21] Implementing UI subject and its business logic (#16)

* update

* implementing methods for loading subjects and terms

* adding subject routes

* implementing default selection by name

* implementing route and view of subject

* implementing subjects screen and business logic

* [EMISANDROI-18] Implement dynamic marks form (#17)

* implementing dynamic form and marks business logic and ui data render

* removing dependency

* implementing dynamic form repository

* form repository dependency injection

* update

* implementing marks screen, ui state and data model ui render

* implementing generic viewmodel class

* model class

* extending generic view model

* methods updates based on generic viewmodel

* adding marks routes

* method name refactor

* removing attendance datastore config and implementing generic props

* removing generic props, unecessary imports and method refactor

* centering text in field and increasing font size

* improving ui state and form state

* removing favorite actions

* marks ui data model rendering

* marks ui state

* removing favorites route and implementing marks route

* [EMISANDROI-24] Implement home page (#18)

* implementing home page

* creating and implementing home route

* refactoring TeiViewModel.kt to HomeViewModel.kt

* routes refactoring

* removing favorites

* update

* implementing routes actions

* implementing viewmodel changes and routes changes

* update

* home dynamic route

* Link homepage to students list (#19)

* [EMISANDROI-26] Performance redesign (#20)

* update

* transforming dropdown to be generic and implementing custom trailing icon feature

* implementing performance features

* class refactor

* class refactor and adding obj prop

* class refactor and loading subjects based on stage

* overriding toString method

* returning subject name of selected subject

* Performance details component

* caching selected stage

* class refactor and ui redesign

* [EMISANDROI-27] Subjects UI redesign (#21)

* adding subjects logo

* removing performance details

* implementing generic ui details

* picking dataElement color

* triggering onItemClick function when it sets default selection

* removing backdrop filter, implementing ui details component and implementing subject item color based on subject prop

* adding subject color

* implementing generic viewModel

* implementing item color based on subject and updating subject icon

* implementing filter details info and setting config based on progra

* creating generic filter selection details

* icon padding

* [EMISANDROI-23] Fix performance fields (#22)

* adding form fields

* implementing intent actions based on icon field action

* setting default selection

* update

* caching collected data, updating fields and implement data save

* implementing performance summary

* loading fields by data element

* implementing performance dialog

* update

* implementing actions steps

* events model

* changing routes params

* [EMISANDROI-28] Disable action cards if the list of selected students is empty (#23)

* [EMISANDROI-29] feat: Implement bulk attendance (#24)

* feat: implement dynamic icons

* feat: implement mocked test case

* chore: strings update

* feat: implement bulk assign component

* chore: update info component to enable/disable bulk attendance

* chore: refactor

* chore: refactor

* chore: add style props

* chore: updating container color style prop

* chore: implementing dynamic icons and dynamic colours attendance button

* chore: refactor

* chore: data class data types update and adding new props

* chore: data class data types update

* feat: implementing bulk attendance dialog

* chore: perform methods moving backend actions to backend

* chore: implementing attendance business logic

* chore: implementing attendance status click action

* chore: performing navigation actions

* chore: collecting ou data

* feat: implement bulk attendance caching

* chore: update attendance route

* feat: implement bulk attendance data collection

* feat(Performance): implement load of default event for each tei

* feat: implement bulk attendance data save

* chore: update merged files

* [EMISANDROI-31] feat: Load and validate status options from the datastore (#25)

* feat: adds RuleEngineRepository injection

* feat: building app RuleEngineRepository

* chore: updates evaluate function and applying coroutines context for rule events

* fix: check k-lint

---------

Co-authored-by: Nelson  Chadali <[email protected]>
  • Loading branch information
CarlosMacaneta and NelsonChad authored Jun 19, 2024
1 parent 9c90538 commit 70f634f
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 94 deletions.
1 change: 0 additions & 1 deletion emis/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ dependencies {
implementation(libs.androidx.material3)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.dagger.hilt.android)
implementation(libs.kotlin.serialization.json)

kapt(libs.dagger.hilt.android.compiler)

Expand Down
2 changes: 2 additions & 0 deletions emis/src/main/java/org/saudigitus/emis/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class MainActivity : FragmentActivity() {
startDestination = AppRoutes.HOME_ROUTE,
) {
composable(AppRoutes.HOME_ROUTE) {
viewModel.setProgram(intent?.extras?.getString(Constants.PROGRAM_UID) ?: "")

HomeScreen(
viewModel = viewModel,
onBack = { finish() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ interface DataManager {
)
suspend fun getConfig(id: String): List<EMISConfigItem>?

/**
* @param ou OrganizationUnit uid
* @param program Program uid
* @param dataElement DataElement uid
*
* Set ou uid and program uid to apply the program rules
*/
suspend fun getOptions(
ou: String?,
program: String?,
dataElement: String,
): List<DropdownItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.saudigitus.emis.data.model.ProgramStage
import org.saudigitus.emis.data.model.Subject
import org.saudigitus.emis.data.model.dto.AttendanceEntity
import org.saudigitus.emis.data.model.dto.withBtnSettings
import org.saudigitus.emis.service.RuleEngineRepository
import org.saudigitus.emis.ui.attendance.AttendanceOption
import org.saudigitus.emis.ui.components.DropdownItem
import org.saudigitus.emis.utils.Constants
Expand All @@ -34,6 +35,7 @@ import org.saudigitus.emis.utils.Utils
import org.saudigitus.emis.utils.eventsWithTrackedDataValues
import org.saudigitus.emis.utils.optionByOptionSet
import org.saudigitus.emis.utils.optionsByOptionSetAndCode
import org.saudigitus.emis.utils.optionsNotInOptionGroup
import timber.log.Timber
import java.sql.Date
import javax.inject.Inject
Expand All @@ -42,6 +44,7 @@ class DataManagerImpl
@Inject constructor(
val d2: D2,
val networkUtils: NetworkUtils,
val ruleEngineRepository: RuleEngineRepository,
) : DataManager {
private fun getAttributeOptionCombo() =
d2.categoryModule().categoryOptionCombos()
Expand Down Expand Up @@ -133,17 +136,36 @@ class DataManagerImpl
}

override suspend fun getOptions(
ou: String?,
program: String?,
dataElement: String,
): List<DropdownItem> = withContext(Dispatchers.IO) {
val optionSet = d2.dataElement(dataElement)?.optionSetUid()

return@withContext d2.optionByOptionSet(optionSet).map {
DropdownItem(
id = it.uid(),
itemName = "${it.displayName()}",
code = it.code() ?: "",
sortOrder = it.sortOrder(),
)
val hideOptions = if (ou != null && program != null) {
ruleEngineRepository.applyOptionRules(ou, program, dataElement)
} else {
emptyList()
}

return@withContext if (hideOptions.isEmpty()) {
d2.optionByOptionSet(optionSet).map {
DropdownItem(
id = it.uid(),
itemName = "${it.displayName()}",
code = it.code() ?: "",
sortOrder = it.sortOrder(),
)
}
} else {
d2.optionsNotInOptionGroup(hideOptions, optionSet).map {
DropdownItem(
id = it.uid(),
itemName = "${it.displayName()}",
code = it.code() ?: "",
sortOrder = it.sortOrder(),
)
}.sortedBy { it.sortOrder }
}
}

Expand Down
15 changes: 0 additions & 15 deletions emis/src/main/java/org/saudigitus/emis/data/model/Favorite.kt

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions emis/src/main/java/org/saudigitus/emis/data/model/Section.kt

This file was deleted.

14 changes: 0 additions & 14 deletions emis/src/main/java/org/saudigitus/emis/data/model/Stream.kt

This file was deleted.

This file was deleted.

8 changes: 7 additions & 1 deletion emis/src/main/java/org/saudigitus/emis/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.saudigitus.emis.data.local.DataManager
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 javax.inject.Singleton

@Module
Expand All @@ -26,12 +27,17 @@ object AppModule {
@ApplicationContext context: Context,
): NetworkUtils = NetworkUtils(context)

@Provides
@Singleton
fun providesRuleEngineRepository(d2: D2) = RuleEngineRepository(d2)

@Provides
@Singleton
fun providesDataManager(
d2: D2,
networkUtils: NetworkUtils,
): DataManager = DataManagerImpl(d2, networkUtils)
ruleEngineRepository: RuleEngineRepository,
): DataManager = DataManagerImpl(d2, networkUtils, ruleEngineRepository)

@Provides
@Singleton
Expand Down
Loading

0 comments on commit 70f634f

Please sign in to comment.