Skip to content

Commit

Permalink
ANDROAPP-1540 Multi text value type
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Feb 28, 2024
1 parent f0df7bd commit 3210a88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fun FieldProvider(
ProvideMultiSelectionInput(
modifier = modifierWithFocus,
fieldUiModel = fieldUiModel,
intentHandler = intentHandler
intentHandler = intentHandler,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.dhis2.form.ui.provider.inputfield

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import org.dhis2.form.extensions.inputState
import org.dhis2.form.extensions.legend
import org.dhis2.form.extensions.supportingText
import org.dhis2.form.model.FieldUiModel
import org.dhis2.form.ui.intent.FormIntent
import org.hisp.dhis.mobile.ui.designsystem.component.CheckBoxData
import org.hisp.dhis.mobile.ui.designsystem.component.MultiSelectInput
import org.hisp.dhis.mobile.ui.designsystem.component.InputMultiSelection

@Composable
internal fun ProvideMultiSelectionInput(
Expand All @@ -21,17 +22,19 @@ internal fun ProvideMultiSelectionInput(
uid = option.uid(),
checked = option.code()?.let { fieldUiModel.value?.contains(it) } ?: false,
enabled = true,
textInput = option.displayName() ?: ""
textInput = option.displayName() ?: "",
)
}

MultiSelectInput(
InputMultiSelection(
modifier = modifier,
title = fieldUiModel.label,
items = data,
state = fieldUiModel.inputState(),
supportingTextData = fieldUiModel.supportingText(),
legendData = fieldUiModel.legend(),
isRequired = fieldUiModel.mandatory,
onItemsSelected = {

val checkedValues = it.filter { item -> item.checked }.mapNotNull {
optionsToDisplay.find { option -> option.uid() == it.uid }?.code()
}
Expand All @@ -40,16 +43,12 @@ internal fun ProvideMultiSelectionInput(
FormIntent.OnSave(
fieldUiModel.uid,
checkedValues.joinToString(separator = ","),
fieldUiModel.valueType
)
fieldUiModel.valueType,
),
)
},
onClearItemSelection = {
intentHandler(FormIntent.ClearValue(fieldUiModel.uid))
}
},
)

/*supportingText = fieldUiModel.supportingText(),
legendData = fieldUiModel.legend(),
isRequired = fieldUiModel.mandatory,*/
}

0 comments on commit 3210a88

Please sign in to comment.