aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/check
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-12 12:00:15 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-12 12:00:15 +0100
commiteea44b35add0d036119888f41e4ed38e75190934 (patch)
tree01ff2b73042ab08941df082d74241dc5e229a37d /src/main/kotlin/pl/treksoft/kvision/form/check
parent4191287261b46b95908469c2ec3fa9d886681861 (diff)
downloadkvision-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/check')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt8
4 files changed, 20 insertions, 12 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
index 4c373a2d..7a8b5905 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
@@ -203,15 +203,17 @@ open class CheckBox(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.checkBox(
value: Boolean = false, label: String? = null,
rich: Boolean = false, init: (CheckBox.() -> Unit)? = null
- ) {
- this.add(CheckBox(value, label, rich).apply { init?.invoke(this) })
+ ): CheckBox {
+ val checkBox = CheckBox(value, label, rich).apply { init?.invoke(this) }
+ this.add(checkBox)
+ return checkBox
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
index 8d083b42..46e5395c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
@@ -183,15 +183,17 @@ open class CheckInput(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.checkInput(
type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false,
classes: Set<String> = setOf(), init: (CheckInput.() -> Unit)? = null
- ) {
- this.add(CheckInput(type, value, classes).apply { init?.invoke(this) })
+ ): CheckInput {
+ val checkInput = CheckInput(type, value, classes).apply { init?.invoke(this) }
+ this.add(checkInput)
+ return checkInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
index 13f4c4cd..ef5d6eb9 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
@@ -223,15 +223,17 @@ open class Radio(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.radio(
value: Boolean = false, extraValue: String? = null, name: String? = null, label: String? = null,
rich: Boolean = false, init: (Radio.() -> Unit)? = null
- ) {
- this.add(Radio(value, extraValue, name, label, rich).apply { init?.invoke(this) })
+ ): Radio {
+ val radio = Radio(value, extraValue, name, label, rich).apply { init?.invoke(this) }
+ this.add(radio)
+ return radio
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
index 80736d59..c7eb5a22 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
@@ -167,15 +167,17 @@ open class RadioGroup(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.radioGroup(
options: List<StringPair>? = null, value: String? = null, inline: Boolean = false,
label: String? = null, rich: Boolean = false, init: (RadioGroup.() -> Unit)? = null
- ) {
- this.add(RadioGroup(options, value, inline, label, rich).apply { init?.invoke(this) })
+ ): RadioGroup {
+ val radioGroup = RadioGroup(options, value, inline, label, rich).apply { init?.invoke(this) }
+ this.add(radioGroup)
+ return radioGroup
}
}
}