Skip to content

Commit

Permalink
version name 3.0 (#3605)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan authored Apr 29, 2024
1 parent ee54635 commit af7b352
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class DashboardViewModel(

private val eventUid = MutableLiveData<String>()

val updateEnrollment = MutableLiveData(false)
val showStatusErrorMessages = MutableLiveData(StatusChangeResultCode.CHANGED)

private var _showFollowUpBar = MutableStateFlow(false)
Expand Down Expand Up @@ -141,7 +140,7 @@ class DashboardViewModel(
_showStatusBar.value = status
_syncNeeded.value = true
_state.value = State.TO_UPDATE
updateEnrollment.postValue(true)
fetchDashboardModel()
} else {
showStatusErrorMessages.postValue(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class TEIDataContracts {

fun showProgramRuleErrorMessage()
fun goToEventInitial(eventCreationType: EventCreationType, programStage: ProgramStage)
fun updateEnrollment(update: Boolean)
fun displayOrgUnitSelectorForNewEvent(programUid: String, programStageUid: String)

fun goToEventDetails(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {

with(dashboardViewModel) {
eventUid().observe(viewLifecycleOwner, ::displayGenerateEvent)
updateEnrollment.observe(viewLifecycleOwner) { update ->
updateEnrollment(update)
}
noEnrollmentSelected.observe(viewLifecycleOwner) { noEnrollmentSelected ->
if (noEnrollmentSelected) {
showAllEnrollment = true
Expand Down Expand Up @@ -387,7 +384,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {
programStageUid,
),
)
presenter.fetchEvents(true)
presenter.fetchEvents()
},
).show(parentFragmentManager, SCHEDULING_DIALOG)
}
Expand Down Expand Up @@ -469,17 +466,17 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {

override fun openEventDetails(intent: Intent, options: ActivityOptionsCompat) =
contractHandler.scheduleEvent(intent, options).observe(viewLifecycleOwner) {
updateEnrollment(true)
presenter.fetchEvents()
}

override fun openEventInitial(intent: Intent) =
contractHandler.editEvent(intent).observe(viewLifecycleOwner) {
updateEnrollment(true)
presenter.fetchEvents()
}

override fun openEventCapture(intent: Intent) =
contractHandler.editEvent(intent).observe(viewLifecycleOwner) {
updateEnrollment(true)
presenter.fetchEvents()
}

override fun goToEventInitial(
Expand Down Expand Up @@ -576,13 +573,6 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {
}
}

override fun updateEnrollment(update: Boolean) {
if (update) {
presenter.fetchEvents(update)
dashboardViewModel.updateDashboard()
}
}

companion object {
const val RC_EVENTS_COMPLETED = 1601
const val PREF_COMPLETED_EVENT = "COMPLETED_EVENT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class TEIDataPresenter(
val intent = Intent(view.context, ProgramStageSelectionActivity::class.java)
intent.putExtras(bundle)
contractHandler.createEvent(intent).observe(view.viewLifecycleOwner()) {
view.updateEnrollment(true)
fetchEvents()
}
}

Expand Down Expand Up @@ -395,10 +395,8 @@ class TEIDataPresenter(
return options?.let { eventCreationOptionsMapper.mapToEventsByStage(it) } ?: emptyList()
}

fun fetchEvents(updateEnrollment: Boolean) {
if (updateEnrollment) {
groupingProcessor.onNext(dashboardRepository.getGrouping())
}
fun fetchEvents() {
groupingProcessor.onNext(dashboardRepository.getGrouping())
}

fun getEnrollment(): Enrollment? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ class DashboardViewModelTest {
whenever(repository.updateEnrollmentStatus(any(), any())) doReturn Observable.just(
StatusChangeResultCode.CHANGED,
)
whenever(mockedEnrollmentModel.currentEnrollment) doReturn mockedCompletedEnrollment
updateEnrollmentStatus(EnrollmentStatus.COMPLETED)
testingDispatcher.scheduler.advanceUntilIdle()
verify(repository).updateEnrollmentStatus("enrollmentUid", EnrollmentStatus.COMPLETED)
assertTrue(showStatusBar.value == EnrollmentStatus.COMPLETED)
assertTrue(syncNeeded.value)
assertTrue(state.value == State.TO_UPDATE)
assertTrue(updateEnrollment.value == true)
}
}

Expand Down Expand Up @@ -187,4 +187,10 @@ class DashboardViewModelTest {
on { aggregatedSyncState() } doReturn State.SYNCED
on { status() } doReturn EnrollmentStatus.ACTIVE
}

private val mockedCompletedEnrollment: Enrollment = mock {
on { uid() } doReturn "enrollmentUid"
on { aggregatedSyncState() } doReturn State.TO_UPDATE
on { status() } doReturn EnrollmentStatus.COMPLETED
}
}

0 comments on commit af7b352

Please sign in to comment.