From 736b80835f67c9c34657074ebcfbe0752bef1c18 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 17 Oct 2019 21:58:34 +0200 Subject: Move DSL builder functions out of the companion objects (#93) --- .../treksoft/kvision/form/select/SimpleSelect.kt | 38 +++++++++++----------- .../kvision/form/select/SimpleSelectInput.kt | 29 ++++++++--------- 2 files changed, 32 insertions(+), 35 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/form/select') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt index bef14bfa..1bcef061 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt @@ -186,24 +186,24 @@ open class SimpleSelect( companion object { internal var counter = 0 - - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.simpleSelect( - options: List? = null, - value: String? = null, - emptyOption: Boolean = false, - name: String? = null, - label: String? = null, - rich: Boolean = false, - init: (SimpleSelect.() -> Unit)? = null - ): SimpleSelect { - val simpleSelect = SimpleSelect(options, value, emptyOption, name, label, rich).apply { init?.invoke(this) } - this.add(simpleSelect) - return simpleSelect - } } } + +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.simpleSelect( + options: List? = null, + value: String? = null, + emptyOption: Boolean = false, + name: String? = null, + label: String? = null, + rich: Boolean = false, + init: (SimpleSelect.() -> Unit)? = null +): SimpleSelect { + val simpleSelect = SimpleSelect(options, value, emptyOption, name, label, rich).apply { init?.invoke(this) } + this.add(simpleSelect) + return simpleSelect +} diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt index 31d32052..bc99f514 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt @@ -199,21 +199,18 @@ open class SimpleSelectInput( override fun blur() { getElementJQuery()?.blur() } +} - companion object { - - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.simpleSelectInput( - options: List? = null, value: String? = null, emptyOption: Boolean = false, - classes: Set = setOf(), init: (SimpleSelectInput.() -> Unit)? = null - ): SimpleSelectInput { - val simpleSelectInput = SimpleSelectInput(options, value, emptyOption, classes).apply { init?.invoke(this) } - this.add(simpleSelectInput) - return simpleSelectInput - } - } +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.simpleSelectInput( + options: List? = null, value: String? = null, emptyOption: Boolean = false, + classes: Set = setOf(), init: (SimpleSelectInput.() -> Unit)? = null +): SimpleSelectInput { + val simpleSelectInput = SimpleSelectInput(options, value, emptyOption, classes).apply { init?.invoke(this) } + this.add(simpleSelectInput) + return simpleSelectInput } -- cgit