From eea44b35add0d036119888f41e4ed38e75190934 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 12 Feb 2018 12:00:15 +0100 Subject: DSL builders returning built components. --- src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt | 8 +++++--- src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/form/select') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt index dc55dd04..2e9b5562 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt @@ -274,7 +274,7 @@ open class Select( internal var counter = 0 /** - * DSL builder extension function + * DSL builder extension function. * * It takes the same parameters as the constructor of the built component. */ @@ -282,8 +282,10 @@ open class Select( options: List? = null, value: String? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null, rich: Boolean = false, init: (Select.() -> Unit)? = null - ) { - this.add(Select(options, value, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) }) + ): Select { + val select = Select(options, value, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) } + this.add(select) + return select } } } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt index be986f02..f90401ce 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt @@ -388,7 +388,7 @@ open class SelectInput( companion object { /** - * DSL builder extension function + * DSL builder extension function. * * It takes the same parameters as the constructor of the built component. */ @@ -396,8 +396,10 @@ open class SelectInput( options: List? = null, value: String? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, classes: Set = setOf(), init: (SelectInput.() -> Unit)? = null - ) { - this.add(SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) }) + ): SelectInput { + val selectInput = SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) } + this.add(selectInput) + return selectInput } } } -- cgit