diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AttachFolderField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AttachFolderField.kt index c893a998..f4893f9c 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AttachFolderField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AttachFolderField.kt @@ -7,8 +7,10 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Attachment +import androidx.compose.material.icons.filled.Clear import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -37,6 +39,7 @@ import com.alfresco.content.process.ui.theme.AlfrescoError fun AttachFolderField( fieldsData: FieldsData = FieldsData(), onUserTap: (Boolean) -> Unit = { }, + onResetFolder: (Boolean) -> Unit = { }, navController: NavController, errorData: Pair = Pair(false, ""), ) { @@ -51,12 +54,6 @@ fun AttachFolderField( val contentValue = (fieldsData.value as? Entry)?.name ?: stringResource(id = R.string.no_attached_folder) - /*val contentValue = if (fieldsData.value == null) { - stringResource(id = R.string.no_attached_folder) - } else { - stringResource(id = R.string.text_attached_folder, 1) - }*/ - val context = LocalContext.current Column( modifier = Modifier @@ -89,16 +86,40 @@ fun AttachFolderField( ) } } - Text( - text = contentValue, - style = TextStyle( - color = MaterialTheme.colorScheme.onPrimary, - fontSize = 12.sp, - ), + + Row( + horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier - .padding(start = 4.dp, top = 0.dp) - .align(alignment = Alignment.Start), - ) + .fillMaxWidth() + .padding(start = 4.dp, end = 12.dp, top = 0.dp), + ) { + Text( + modifier = Modifier + .padding(top = 0.dp) + .align(alignment = Alignment.CenterVertically), + text = contentValue, + style = TextStyle( + color = MaterialTheme.colorScheme.onPrimary, + fontSize = 12.sp, + ), + ) + if (fieldsData.value != null) { + IconButton( + onClick = { + onResetFolder(true) + }, + modifier = Modifier + .size(20.dp) + .padding(top = 0.dp), + ) { + Icon( + imageVector = Icons.Default.Clear, + tint = AlfrescoBlue300, + contentDescription = "", + ) + } + } + } } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScrollContent.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScrollContent.kt index ddf7c73b..e3618279 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScrollContent.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/composeviews/FormScrollContent.kt @@ -34,6 +34,7 @@ import com.alfresco.content.process.ui.utils.amountInputError import com.alfresco.content.process.ui.utils.booleanInputError import com.alfresco.content.process.ui.utils.dateTimeInputError import com.alfresco.content.process.ui.utils.dropDownRadioInputError +import com.alfresco.content.process.ui.utils.folderInputError import com.alfresco.content.process.ui.utils.integerInputError import com.alfresco.content.process.ui.utils.multiLineInputError import com.alfresco.content.process.ui.utils.singleLineInputError @@ -250,6 +251,12 @@ fun FormScrollContent(field: FieldsData, viewModel: FormViewModel, state: FormVi viewModel.selectedField = field } }, + onResetFolder = { + if (it) { + val errorData = folderInputError(null, field, context) + viewModel.updateFieldValue(field.id, null, errorData) + } + }, ) } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/utils/Utils.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/utils/Utils.kt index 56c19e79..2a2a852e 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/utils/Utils.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/utils/Utils.kt @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import com.alfresco.content.data.Entry import com.alfresco.content.data.UserGroupDetails import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R @@ -145,3 +146,10 @@ fun userGroupInputError(value: UserGroupDetails?, fieldsData: FieldsData, contex return Pair(isError, errorMessage) } +fun folderInputError(value: Entry?, fieldsData: FieldsData, context: Context): Pair { + val isError = (fieldsData.required && value == null) + + val errorMessage = "" + + return Pair(isError, errorMessage) +}