Skip to content

Commit

Permalink
Add delete draft workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Rkareko committed Nov 22, 2024
1 parent 8ee171a commit 83dcf5b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ enum class ApplicationWorkflow {

/** A workflow to launch pdf generation */
LAUNCH_PDF_GENERATION,

/** A workflow to launch delete draft */
LAUNCH_DELETE_DRAFT_FORM,

Check warning on line 67 in android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/workflow/ApplicationWorkflow.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/workflow/ApplicationWorkflow.kt#L67

Added line #L67 was not covered by tests
}
2 changes: 2 additions & 0 deletions android/engine/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
<string name="questionnaire_alert_invalid_message">Given details have validation errors. Resolve errors and submit again</string>
<string name="questionnaire_alert_invalid_title">Validation Failed</string>
<string name="questionnaire_alert_ack_button_title">OK</string>
<string name="questionnaire_alert_open_draft_button_title">Open draft</string>
<string name="questionnaire_alert_delete_draft_button_title">Delete draft</string>
<string name="username">Username</string>
<string name="password">Password</string>
<string name="forgot_password">Forgot Password</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ sealed class MainNavigationScreen(
route = org.smartregister.fhircore.quest.R.id.summaryBottomSheetFragment,
)

data object AlertDialogFragment :
MainNavigationScreen(
route = org.smartregister.fhircore.quest.R.id.alertDialogFragment,
)

fun eventId(id: String) = route.toString() + "_" + id
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ object NavigationArg {
const val REPORT_ID = "reportId"
const val PARAMS = "params"
const val TOOL_BAR_HOME_NAVIGATION = "toolBarHomeNavigation"
const val QUESTIONNAIRE_CONFIG = "questionnaireConfig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.smartregister.fhircore.quest.ui.dialog

import android.app.Dialog
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import androidx.navigation.fragment.navArgs
import org.smartregister.fhircore.engine.ui.base.AlertDialogue
import org.smartregister.fhircore.quest.ui.shared.QuestionnaireHandler

class AlertDialogFragment() : DialogFragment() {

private val alertDialogFragmentArgs by navArgs<AlertDialogFragmentArgs>()

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return AlertDialogue.showCancelAlert(
context = requireContext(),
message =
org.smartregister.fhircore.engine.R.string
.questionnaire_in_progress_alert_back_pressed_message,
title = org.smartregister.fhircore.engine.R.string.questionnaire_alert_back_pressed_title,
confirmButtonListener = {
if (requireContext() is QuestionnaireHandler) {
(requireContext() as QuestionnaireHandler).launchQuestionnaire(
context = requireContext(),
questionnaireConfig = alertDialogFragmentArgs.questionnaireConfig,
actionParams = listOf(),
)
}
},
confirmButtonText =
org.smartregister.fhircore.engine.R.string.questionnaire_alert_open_draft_button_title,
neutralButtonListener = {},
neutralButtonText =
org.smartregister.fhircore.engine.R.string.questionnaire_alert_neutral_button_title,
negativeButtonListener = { this.dismiss() },
negativeButtonText =
org.smartregister.fhircore.engine.R.string.questionnaire_alert_delete_draft_button_title,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ fun ActionConfig.handleClickEvent(
val appCompatActivity = (navController.context as AppCompatActivity)
PdfLauncherFragment.launch(appCompatActivity, interpolatedPdfConfig.encodeJson())
}
ApplicationWorkflow.LAUNCH_DELETE_DRAFT_FORM -> {
val args =
bundleOf(
NavigationArg.QUESTIONNAIRE_CONFIG to actionConfig.questionnaire,
)
navController.navigate(MainNavigationScreen.AlertDialogFragment.route, args)
}
else -> return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,12 @@
android:name="org.smartregister.fhircore.quest.ui.bottomsheet.SummaryBottomSheetFragment" >

</dialog>
<dialog
android:id="@+id/alertDialogFragment"
android:name="org.smartregister.fhircore.quest.ui.dialog.AlertDialogFragment" >
<argument
android:name="questionnaireConfig"
app:argType="org.smartregister.fhircore.engine.configuration.QuestionnaireConfig"
app:nullable="true" />
</dialog>
</navigation>

0 comments on commit 83dcf5b

Please sign in to comment.