-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [ANDROAPP-6608] Display enrollment form error/warning dialog in …
…landscape dashboard (#3865)
- Loading branch information
Showing
18 changed files
with
286 additions
and
272 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
app/src/main/java/org/dhis2/usescases/enrollment/DateEditionWarningHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.dhis2.usescases.enrollment | ||
|
||
import org.dhis2.R | ||
import org.dhis2.commons.resources.EventResourcesProvider | ||
import org.dhis2.form.data.EnrollmentRepository | ||
import org.dhis2.form.data.metadata.EnrollmentConfiguration | ||
|
||
class DateEditionWarningHandler( | ||
private val conf: EnrollmentConfiguration?, | ||
private val eventResourcesProvider: EventResourcesProvider, | ||
) { | ||
private var hasShownIncidentDateEditionWarning = false | ||
private var hasShownEnrollmentDateEditionWarning = false | ||
|
||
fun shouldShowWarning( | ||
fieldUid: String, | ||
showWarning: (message: String) -> Unit, | ||
) { | ||
if (fieldUid == EnrollmentRepository.ENROLLMENT_DATE_UID && | ||
conf?.hasEventsGeneratedByEnrollmentDate() == true && | ||
!hasShownEnrollmentDateEditionWarning | ||
) { | ||
hasShownEnrollmentDateEditionWarning = true | ||
showWarning(buildMessage()) | ||
} else if (fieldUid == EnrollmentRepository.INCIDENT_DATE_UID && | ||
conf?.hasEventsGeneratedByIncidentDate() == true && | ||
!hasShownIncidentDateEditionWarning | ||
) { | ||
hasShownIncidentDateEditionWarning = true | ||
showWarning(buildMessage()) | ||
} | ||
} | ||
|
||
private fun buildMessage() = eventResourcesProvider.formatWithProgramEventLabel( | ||
R.string.enrollment_date_edition_warning_event_label, | ||
conf?.program()?.uid(), | ||
2, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.