From eab2b98fdfbbd90134f805b6efc1a8b9168c6700 Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 27 Feb 2024 11:18:48 +0100 Subject: [PATCH 1/2] fix: [ANDROAPP-5802] scheduling dialog not displayed --- .../teidata/TEIDataFragment.kt | 28 +++++++++---------- .../teidata/TEIDataPresenter.kt | 9 +++++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index cbb5eb6baf..bd409f8276 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -25,7 +25,6 @@ import org.dhis2.bindings.app import org.dhis2.commons.Constants import org.dhis2.commons.data.EventCreationType import org.dhis2.commons.data.EventViewModel -import org.dhis2.commons.data.EventViewModelType import org.dhis2.commons.data.StageSection import org.dhis2.commons.dialogs.CustomDialog import org.dhis2.commons.dialogs.DialogClickListener @@ -217,14 +216,16 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { ) } - if (sharedPreferences.getString(PREF_COMPLETED_EVENT, null) != null) { - presenter.displayGenerateEvent( - sharedPreferences.getString( - PREF_COMPLETED_EVENT, - null, - ), - ) - sharedPreferences.edit().remove(PREF_COMPLETED_EVENT).apply() + dashboardViewModel.dashboardModel.observe(viewLifecycleOwner) { + if (sharedPreferences.getString(PREF_COMPLETED_EVENT, null) != null) { + presenter.displayGenerateEvent( + sharedPreferences.getString( + PREF_COMPLETED_EVENT, + null, + ), + ) + sharedPreferences.edit().remove(PREF_COMPLETED_EVENT).apply() + } } }.root } @@ -318,10 +319,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { if (model is DashboardEnrollmentModel) { SchedulingDialog( enrollment = model.currentEnrollment, - programStages = eventAdapter?.currentList - ?.filter { it.type == EventViewModelType.STAGE && it.canAddNewEvent } - ?.mapNotNull { it.stage } - ?: emptyList(), + programStages = presenter.filterAvailableStages(model.programStages), onScheduled = { programStageUid -> showToast( resourceManager.formatWithEventLabel( @@ -331,7 +329,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { ) presenter.fetchEvents(true) }, - ).show(childFragmentManager, SCHEDULING_DIALOG) + ).show(parentFragmentManager, SCHEDULING_DIALOG) } } @@ -389,7 +387,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { } override fun displayGenerateEvent(eventUid: String) { - presenter.displayGenerateEvent(eventUid) + // presenter.displayGenerateEvent(eventUid) dashboardViewModel.updateEventUid(null) } diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt index 4327fb1d80..1c90e4157a 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt @@ -101,7 +101,8 @@ class TEIDataPresenter( compositeDisposable.add( Flowable.combineLatest>( sectionFlowable, - groupingFlowable, ::Pair, + groupingFlowable, + ::Pair, ) .doOnNext { increment() } .switchMap { stageAndGrouping -> @@ -429,4 +430,10 @@ class TEIDataPresenter( fun getEnrollment(): Enrollment? { return teiDataRepository.getEnrollment().blockingGet() } + + fun filterAvailableStages(programStages: List): List = + programStages + .filter { it.repeatable() == true } + .filter { it.access().data().write() } + .filter { !stagesToHide.contains(it.uid()) } } From e446de848b92f1821175b97e9b9638a9e72b5b6e Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 27 Feb 2024 11:21:04 +0100 Subject: [PATCH 2/2] fix: [ANDROAPP-5802] scheduling dialog not displayed --- .../teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index bd409f8276..95f5d7daf5 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -387,7 +387,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { } override fun displayGenerateEvent(eventUid: String) { - // presenter.displayGenerateEvent(eventUid) + presenter.displayGenerateEvent(eventUid) dashboardViewModel.updateEventUid(null) }