From e36ac01a8ea3fc16c2d28bda5588a0da860dde0a Mon Sep 17 00:00:00 2001
From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com>
Date: Tue, 2 Apr 2024 14:23:00 +0530
Subject: [PATCH] added confirmation dialog if any of the file is not uploaded
---
browse/src/main/res/values-de/strings.xml | 2 --
browse/src/main/res/values-es/strings.xml | 2 --
browse/src/main/res/values-fr/strings.xml | 2 --
browse/src/main/res/values-it/strings.xml | 2 --
browse/src/main/res/values-nl/strings.xml | 2 --
browse/src/main/res/values/strings.xml | 2 --
common/src/main/res/values-de/strings.xml | 2 ++
common/src/main/res/values-es/strings.xml | 2 ++
common/src/main/res/values-fr/strings.xml | 3 ++-
common/src/main/res/values-it/strings.xml | 2 ++
common/src/main/res/values-nl/strings.xml | 2 ++
common/src/main/res/values/strings.xml | 4 ++-
.../ui/components/FloatingActionButton.kt | 27 ++++++++++++-------
.../content/process/ui/components/Outcomes.kt | 16 ++++++++---
.../ui/composeviews/FormDetailScreen.kt | 10 ++++---
.../process/ui/composeviews/FormScreen.kt | 18 +++++--------
.../process/ui/fragments/FormViewModel.kt | 1 +
.../process/ui/fragments/ProcessFragment.kt | 27 +++++++++++++++++++
18 files changed, 86 insertions(+), 40 deletions(-)
diff --git a/browse/src/main/res/values-de/strings.xml b/browse/src/main/res/values-de/strings.xml
index 21922108..2a9969d8 100755
--- a/browse/src/main/res/values-de/strings.xml
+++ b/browse/src/main/res/values-de/strings.xml
@@ -90,8 +90,6 @@
Filteroption %s
Workflows sind für diesen Account nicht aktiviert.
- Warnung
- Das Hochladen von Dateien ist in Bearbeitung. Tippen Sie auf Bestätigen, um ohne laufende Dateien fortzufahren.
Genehmigen
Ablehnen
Erneut zur Genehmigung senden
diff --git a/browse/src/main/res/values-es/strings.xml b/browse/src/main/res/values-es/strings.xml
index 848a60da..661bebdb 100755
--- a/browse/src/main/res/values-es/strings.xml
+++ b/browse/src/main/res/values-es/strings.xml
@@ -91,8 +91,6 @@
Flujos de trabajo no disponibles
Los flujos de trabajo aparecerán aquí cuando sean creados
- Advertencia
- La carga de ficheros está en curso. Toque Confirmar para continuar sin los ficheros en curso.
Aprobar
Rechazar
Enviar para aprobación otra vez
diff --git a/browse/src/main/res/values-fr/strings.xml b/browse/src/main/res/values-fr/strings.xml
index 2adb0131..5ca8258e 100755
--- a/browse/src/main/res/values-fr/strings.xml
+++ b/browse/src/main/res/values-fr/strings.xml
@@ -90,8 +90,6 @@
Option de filtre %s
Les workflows ne sont pas activées pour ce compte.
- Avertissement
- Le téléchargement des fichiers est en cours. Tapez sur Confirmer pour continuer sans fichiers en cours.
Approuver
Rejeter
Envoyer à nouveau pour approbation
diff --git a/browse/src/main/res/values-it/strings.xml b/browse/src/main/res/values-it/strings.xml
index 3ed4d8bf..86f11ed1 100755
--- a/browse/src/main/res/values-it/strings.xml
+++ b/browse/src/main/res/values-it/strings.xml
@@ -90,8 +90,6 @@
Opzione di filtro %s
I workflow non sono abilitati per questo account.
- Avviso
- Il caricamento dei file è in corso. Toccare su Conferma per continuare senza questi file.
Approva
Respingi
Invia di nuovo per approvazione
diff --git a/browse/src/main/res/values-nl/strings.xml b/browse/src/main/res/values-nl/strings.xml
index acfaad46..6d1b2ee4 100755
--- a/browse/src/main/res/values-nl/strings.xml
+++ b/browse/src/main/res/values-nl/strings.xml
@@ -90,8 +90,6 @@
Workflows niet beschikbaar!
Wanneer workflows zijn gemaakt, worden deze hier weergegeven.
- Waarschuwing
- Er worden bestanden geüpload. Tik om te bevestigen dat u wilt doorgaan zonder de bestanden in uitvoering.
Goedkeuren
Afwijzen
Nogmaals verzenden voor goedkeuring
diff --git a/browse/src/main/res/values/strings.xml b/browse/src/main/res/values/strings.xml
index 70fed651..7a6ae97a 100644
--- a/browse/src/main/res/values/strings.xml
+++ b/browse/src/main/res/values/strings.xml
@@ -90,8 +90,6 @@
Filter Option %s
Workflows are not enabled for this account.
- Warning
- Files uploading is in progress. Tap on Confirm to continue without in-progress files.
Approve
Reject
Send for Approval Again
diff --git a/common/src/main/res/values-de/strings.xml b/common/src/main/res/values-de/strings.xml
index db7a9831..56591e2e 100755
--- a/common/src/main/res/values-de/strings.xml
+++ b/common/src/main/res/values-de/strings.xml
@@ -39,4 +39,6 @@
Abbrechen
Bestätigen
Abgeschlossen
+ Warnung
+ Das Hochladen von Dateien ist in Bearbeitung. Tippen Sie auf Bestätigen, um ohne laufende Dateien fortzufahren.
diff --git a/common/src/main/res/values-es/strings.xml b/common/src/main/res/values-es/strings.xml
index 27da0c1f..66ffe12b 100755
--- a/common/src/main/res/values-es/strings.xml
+++ b/common/src/main/res/values-es/strings.xml
@@ -39,4 +39,6 @@
Cancelar
Confirmar
Por completar
+ Advertencia
+ La carga de ficheros está en curso. Toque Confirmar para continuar sin los ficheros en curso.
diff --git a/common/src/main/res/values-fr/strings.xml b/common/src/main/res/values-fr/strings.xml
index 14f80baf..71f632d2 100755
--- a/common/src/main/res/values-fr/strings.xml
+++ b/common/src/main/res/values-fr/strings.xml
@@ -39,5 +39,6 @@
Annuler
Confirmer
Terminé
-
+ Avertissement
+ Le téléchargement des fichiers est en cours. Tapez sur Confirmer pour continuer sans fichiers en cours.
diff --git a/common/src/main/res/values-it/strings.xml b/common/src/main/res/values-it/strings.xml
index a76a252f..96b80a53 100755
--- a/common/src/main/res/values-it/strings.xml
+++ b/common/src/main/res/values-it/strings.xml
@@ -39,4 +39,6 @@
Ignora
Vuoi ignorare le modifiche?
Completato
+ Avviso
+ Il caricamento dei file è in corso. Toccare su Conferma per continuare senza questi file.
diff --git a/common/src/main/res/values-nl/strings.xml b/common/src/main/res/values-nl/strings.xml
index 6ad781d6..2b8d8126 100755
--- a/common/src/main/res/values-nl/strings.xml
+++ b/common/src/main/res/values-nl/strings.xml
@@ -39,4 +39,6 @@
Annuleren
Bevestigen
Voltooien
+ Waarschuwing
+ Er worden bestanden geüpload. Tik om te bevestigen dat u wilt doorgaan zonder de bestanden in uitvoering.
diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index d4ad9145..a8a7dffc 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -39,5 +39,7 @@
Delete a file?
Cancel
Confirm
- Complete
+ CompleteWarning
+ Files uploading is in progress. Tap on Confirm to continue without in-progress files.
+
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt
index 1966bc83..3195f0ca 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt
@@ -7,21 +7,25 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
+import com.airbnb.mvrx.compose.collectAsState
import com.alfresco.content.component.ComponentBuilder
import com.alfresco.content.component.ComponentData
import com.alfresco.content.data.OptionsModel
import com.alfresco.content.process.R
import com.alfresco.content.process.ui.fragments.FormViewModel
+import com.alfresco.content.process.ui.fragments.ProcessFragment
@Composable
-fun FloatingActionButton(outcomes: List, enabledOutcomes: Boolean, viewModel: FormViewModel) {
+fun FloatingActionButton(outcomes: List, fragment: ProcessFragment, viewModel: FormViewModel) {
val context = LocalContext.current
+ val state by viewModel.collectAsState()
ExtendedFloatingActionButton(
onClick = {
- if (enabledOutcomes) {
+ if (state.enabledOutcomes) {
val componentData = ComponentData.with(
outcomes,
"",
@@ -29,13 +33,18 @@ fun FloatingActionButton(outcomes: List, enabledOutcomes: Boolean,
)
ComponentBuilder(context, componentData)
.onApply { name, query, _ ->
-
- viewModel.performOutcomes(
- OptionsModel(
- id = query,
- name = name,
- ),
- )
+ val entry = state.listContents.find { it.isUpload }
+ if (entry != null) {
+ viewModel.optionsModel = OptionsModel(id = query, name = name)
+ fragment.confirmContentQueuePrompt()
+ } else {
+ viewModel.performOutcomes(
+ OptionsModel(
+ id = query,
+ name = name,
+ ),
+ )
+ }
}
.onReset { name, query, _ ->
}
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt
index b3ac4d83..4a904293 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt
@@ -7,24 +7,34 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
+import com.airbnb.mvrx.compose.collectAsState
import com.alfresco.content.data.OptionsModel
import com.alfresco.content.process.ui.fragments.FormViewModel
+import com.alfresco.content.process.ui.fragments.ProcessFragment
@Composable
-fun Outcomes(outcomes: List, enabledOutcomes: Boolean, viewModel: FormViewModel) {
+fun Outcomes(outcomes: List, viewModel: FormViewModel, fragment: ProcessFragment) {
+ val state by viewModel.collectAsState()
outcomes.forEach {
Button(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 4.dp),
onClick = {
- viewModel.performOutcomes(it)
+ val entry = state.listContents.find { it.isUpload }
+ if (entry != null) {
+ viewModel.optionsModel = it
+ fragment.confirmContentQueuePrompt()
+ } else {
+ viewModel.performOutcomes(it)
+ }
},
shape = RoundedCornerShape(6.dp),
- enabled = enabledOutcomes,
+ enabled = state.enabledOutcomes,
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
),
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormDetailScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormDetailScreen.kt
index b0968783..b8aa5d8a 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormDetailScreen.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormDetailScreen.kt
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
@@ -17,16 +18,19 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
+import com.airbnb.mvrx.compose.collectAsState
import com.alfresco.content.data.OptionsModel
import com.alfresco.content.data.TaskRepository
import com.alfresco.content.process.ui.components.Outcomes
import com.alfresco.content.process.ui.fragments.FormViewModel
import com.alfresco.content.process.ui.fragments.FormViewState
+import com.alfresco.content.process.ui.fragments.ProcessFragment
@SuppressLint("MutableCollectionMutableState")
@Composable
-fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel, outcomes: List, navController: NavController) {
+fun FormDetailScreen(viewModel: FormViewModel, outcomes: List, navController: NavController, fragment: ProcessFragment) {
val keyboardController = LocalSoftwareKeyboardController.current
+ val state by viewModel.collectAsState()
val focusManager = LocalFocusManager.current
Column(
@@ -61,7 +65,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel, outcomes: L
.fillMaxWidth()
.align(alignment = Alignment.CenterHorizontally),
) {
- Outcomes(outcomes = outcomes, state.enabledOutcomes, viewModel)
+ Outcomes(outcomes = outcomes, viewModel, fragment)
}
}
}
@@ -72,7 +76,6 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel, outcomes: L
fun PreviewProcessDetailScreen() {
val state = FormViewState()
FormDetailScreen(
- state,
FormViewModel(
state,
LocalContext.current,
@@ -80,5 +83,6 @@ fun PreviewProcessDetailScreen() {
),
emptyList(),
rememberNavController(),
+ ProcessFragment(),
)
}
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScreen.kt
index 8172fb2b..f33a2b84 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScreen.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScreen.kt
@@ -17,19 +17,15 @@ import com.alfresco.content.process.R
import com.alfresco.content.process.ui.components.FloatingActionButton
import com.alfresco.content.process.ui.fragments.FormViewModel
import com.alfresco.content.process.ui.fragments.FormViewState
+import com.alfresco.content.process.ui.fragments.ProcessFragment
@Composable
-fun FormScreen(navController: NavController, viewModel: FormViewModel) {
+fun FormScreen(navController: NavController, viewModel: FormViewModel, fragment: ProcessFragment) {
val state by viewModel.collectAsState()
val customOutcomes = when {
- state.formFields.isNotEmpty() && state.processOutcomes.isEmpty() -> {
- defaultOutcomes(state)
- }
-
- else -> {
- customOutcomes(state)
- }
+ state.formFields.isNotEmpty() && state.processOutcomes.isEmpty() -> defaultOutcomes(state)
+ else -> customOutcomes(state)
}
when {
@@ -43,14 +39,14 @@ fun FormScreen(navController: NavController, viewModel: FormViewModel) {
color = colorScheme.background,
contentColor = colorScheme.onBackground,
) {
- FormDetailScreen(state, viewModel, customOutcomes, navController)
+ FormDetailScreen(viewModel, customOutcomes, navController, fragment)
}
}
}
else -> {
Scaffold(
- floatingActionButton = { FloatingActionButton(customOutcomes, state.enabledOutcomes, viewModel) },
+ floatingActionButton = { FloatingActionButton(customOutcomes, fragment, viewModel) },
floatingActionButtonPosition = FabPosition.End,
) { padding ->
val colorScheme = MaterialTheme.colorScheme
@@ -61,7 +57,7 @@ fun FormScreen(navController: NavController, viewModel: FormViewModel) {
color = colorScheme.background,
contentColor = colorScheme.onBackground,
) {
- FormDetailScreen(state, viewModel, emptyList(), navController)
+ FormDetailScreen(viewModel, emptyList(), navController, fragment)
}
}
}
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt
index 154609f6..a1ef1cce 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt
@@ -38,6 +38,7 @@ class FormViewModel(
var observerID: String = ""
var folderFieldId = ""
private var entryListener: EntryListener? = null
+ var optionsModel: OptionsModel? = null
init {
observerID = UUID.randomUUID().toString()
diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt
index 82f8a824..4e165be6 100644
--- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt
+++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt
@@ -8,6 +8,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.view.isVisible
@@ -27,6 +28,8 @@ import com.alfresco.content.process.databinding.FragmentProcessBinding
import com.alfresco.content.process.ui.components.updateProcessList
import com.alfresco.content.process.ui.composeviews.FormScreen
import com.alfresco.content.process.ui.theme.AlfrescoBaseTheme
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
+import java.lang.ref.WeakReference
class ProcessFragment : Fragment(), MavericksView, EntryListener {
@@ -34,6 +37,7 @@ class ProcessFragment : Fragment(), MavericksView, EntryListener {
lateinit var binding: FragmentProcessBinding
private var viewLayout: View? = null
private var menu: Menu? = null
+ private var confirmContentQueueDialog = WeakReference(null)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -97,6 +101,7 @@ class ProcessFragment : Fragment(), MavericksView, EntryListener {
FormScreen(
navController = findNavController(),
viewModel = viewModel,
+ this@ProcessFragment,
)
}
}
@@ -126,4 +131,26 @@ class ProcessFragment : Fragment(), MavericksView, EntryListener {
viewModel.folderFieldId = ""
}
}
+
+ /**
+ * It will prompt if user trying to start workflow and if any of content file is in uploaded
+ */
+ fun confirmContentQueuePrompt() {
+ val oldDialog = confirmContentQueueDialog.get()
+ if (oldDialog != null && oldDialog.isShowing) return
+ val dialog = MaterialAlertDialogBuilder(requireContext())
+ .setCancelable(false)
+ .setTitle(getString(R.string.title_content_in_queue))
+ .setMessage(getString(R.string.message_content_in_queue))
+ .setNegativeButton(getString(R.string.dialog_negative_button_task), null)
+ .setPositiveButton(getString(R.string.dialog_positive_button_task)) { _, _ ->
+ viewModel.optionsModel?.let {
+ viewModel.performOutcomes(
+ it,
+ )
+ }
+ }
+ .show()
+ confirmContentQueueDialog = WeakReference(dialog)
+ }
}