diff --git a/data/src/main/kotlin/com/alfresco/content/data/payloads/FieldsData.kt b/data/src/main/kotlin/com/alfresco/content/data/payloads/FieldsData.kt index f584c33f..fca0125a 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/payloads/FieldsData.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/payloads/FieldsData.kt @@ -81,6 +81,7 @@ enum class FieldType { READONLY, PEOPLE, FUNCTIONAL_GROUP, + HYPERLINK, ; fun value() = name.lowercase() diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/FormViewModel.kt b/process-app/src/main/kotlin/com/alfresco/content/process/FormViewModel.kt index 04dc60e1..b71503ac 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/FormViewModel.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/FormViewModel.kt @@ -14,6 +14,7 @@ import com.alfresco.content.data.ProcessEntry import com.alfresco.content.data.ResponseListForm import com.alfresco.content.data.ResponseListProcessDefinition import com.alfresco.content.data.TaskRepository +import com.alfresco.content.data.UserGroupDetails import com.alfresco.content.data.payloads.FieldsData import com.alfresco.coroutines.asFlow import kotlinx.coroutines.launch @@ -91,7 +92,7 @@ class FormViewModel( } } - fun updateFieldValue(fieldId: String, newValue: String, state: FormViewState) { + fun updateFieldValue(fieldId: String, newValue: Any?, state: FormViewState) { val updatedFields = state.copy( formFields = state.formFields.map { field -> if (field.id == fieldId) { diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt index 85a8cf4d..6b23bcd3 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt @@ -42,7 +42,9 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { val keyboardController = LocalSoftwareKeyboardController.current val focusManager = LocalFocusManager.current - val formList = state.formFields.map { it } + val formList by remember(state.formFields) { + mutableStateOf(state.formFields.map { it }) + } Column( modifier = Modifier @@ -55,7 +57,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally, - ) { + ) { LazyColumn( modifier = Modifier .fillMaxSize(), @@ -117,6 +119,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { checkedValue = checkedValue, onCheckChanged = { newChecked -> checkedValue = newChecked + viewModel.updateFieldValue(field.id, newChecked, state) }, field, ) @@ -128,6 +131,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { dateTimeValue = textFieldValue, onValueChanged = { newText -> textFieldValue = newText + viewModel.updateFieldValue(field.id, newText, state) }, field, ) @@ -142,6 +146,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { onValueChanged = { (newText, newQuery) -> textFieldValue = newText textFieldQuery = newQuery + viewModel.updateFieldValue(field.id, newText, state) }, fieldsData = field, ) @@ -156,16 +161,21 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { } FieldType.PEOPLE.value(), FieldType.FUNCTIONAL_GROUP.value() -> { - var userDetailValue by remember { mutableStateOf(null) } + var userDetailValue by remember { mutableStateOf(field.value as? UserGroupDetails) } PeopleField( userDetail = userDetailValue, onAssigneeSelected = { userDetails -> userDetailValue = userDetails + viewModel.updateFieldValue(field.id, userDetails, state) }, fieldsData = field, processEntry = ProcessEntry.withProcess(state.parent, field.type), ) } + + FieldType.HYPERLINK.value() -> { + + } } } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt index 7ccd6042..8fec477f 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt @@ -138,6 +138,8 @@ private fun customLabel(visibleText: String, showReadMoreButtonState: Boolean, f val startIndexReadMore = labelReadMore.indexOf(readMore) val endIndexReadMore = startIndexReadMore + readMore.length + println("startIndexReadMore == $startIndexReadMore") + val startIndexAsteric = labelReadMore.indexOf(spaceAsteric) val endIndexAsteric = startIndexAsteric + spaceAsteric.length @@ -153,7 +155,7 @@ private fun customLabel(visibleText: String, showReadMoreButtonState: Boolean, f addStyle( style = SpanStyle(color = MaterialTheme.colorScheme.primary), - start = startIndexReadMore, + start = startIndexReadMore + 1, end = endIndexReadMore, )