
com.slack.api.model.kotlin_extension.block.element.RadioButtonsElementBuilder.kt Maven / Gradle / Ivy
package com.slack.api.model.kotlin_extension.block.element
import com.slack.api.model.block.composition.ConfirmationDialogObject
import com.slack.api.model.block.composition.OptionObject
import com.slack.api.model.block.element.RadioButtonsElement
import com.slack.api.model.kotlin_extension.block.BlockLayoutBuilder
import com.slack.api.model.kotlin_extension.block.Builder
import com.slack.api.model.kotlin_extension.block.composition.ConfirmationDialogObjectBuilder
import com.slack.api.model.kotlin_extension.block.composition.OptionObjectBuilder
import com.slack.api.model.kotlin_extension.block.composition.container.MultiOptionContainer
import com.slack.api.model.kotlin_extension.block.composition.dsl.OptionObjectDsl
@BlockLayoutBuilder
class RadioButtonsElementBuilder : Builder {
private var actionId: String? = null
private var options: List? = null
private var initialOption: OptionObject? = null
private var confirm: ConfirmationDialogObject? = null
private var _focusOnLoad: Boolean? = null
/**
* An identifier for the action triggered when the radio button group is changed. You can use this when you
* receive an interaction payload to identify the source of the action. Should be unique among all other
* action_ids used elsewhere by your app. Maximum length for this field is 255 characters.
*
* @see Radio buttons element documentation
*/
fun actionId(id: String) {
actionId = id
}
/**
* An array of option objects.
*
* @see Radio buttons element documentation
*/
fun options(builder: OptionObjectDsl.() -> Unit) {
options = MultiOptionContainer().apply(builder).underlying
}
/**
* An option object that exactly matches one of the options within options. This option will be selected when the
* radio button group initially loads.
*
* @see Radio buttons element documentation
*/
fun initialOption(builder: OptionObjectBuilder.() -> Unit) {
initialOption = OptionObjectBuilder().apply(builder).build()
}
/**
* A confirm object that defines an optional confirmation dialog that appears after clicking one of the radio
* buttons in this element.
*
* @see Radio buttons element documentation
*/
fun confirm(builder: ConfirmationDialogObjectBuilder.() -> Unit) {
confirm = ConfirmationDialogObjectBuilder().apply(builder).build()
}
/**
* Indicates whether the element will be set to autofocus within the view object.
* Only one element can be set to true. Defaults to false.
*
* @see Radio buttons element documentation
*/
fun focusOnLoad(focusOnLoad: Boolean) {
_focusOnLoad = focusOnLoad
}
override fun build(): RadioButtonsElement {
return RadioButtonsElement.builder()
.actionId(actionId)
.options(options)
.initialOption(initialOption)
.confirm(confirm)
.focusOnLoad(_focusOnLoad)
.build()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy