diff options
| author | Robert Jaros <rjaros@finn.pl> | 2018-02-12 12:00:15 +0100 |
|---|---|---|
| committer | Robert Jaros <rjaros@finn.pl> | 2018-02-12 12:00:15 +0100 |
| commit | eea44b35add0d036119888f41e4ed38e75190934 (patch) | |
| tree | 01ff2b73042ab08941df082d74241dc5e229a37d /src/main/kotlin/pl/treksoft/kvision/form/select | |
| parent | 4191287261b46b95908469c2ec3fa9d886681861 (diff) | |
| download | kvision-eea44b35add0d036119888f41e4ed38e75190934.tar.gz kvision-eea44b35add0d036119888f41e4ed38e75190934.tar.bz2 kvision-eea44b35add0d036119888f41e4ed38e75190934.zip | |
DSL builders returning built components.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/select')
| -rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt | 8 | ||||
| -rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt | 8 |
2 files changed, 10 insertions, 6 deletions
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<StringPair>? = 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<StringPair>? = null, value: String? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, classes: Set<String> = 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 } } } |
