aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/text
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/text
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/text')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt8
7 files changed, 35 insertions, 21 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
index 39c9a306..e2f9ab93 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
@@ -37,14 +37,16 @@ open class Password(value: String? = null, label: String? = null, rich: Boolean
) {
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.password(
value: String? = null, label: String? = null, rich: Boolean = false, init: (Password.() -> Unit)? = null
- ) {
- this.add(Password(value, label, rich).apply { init?.invoke(this) })
+ ): Password {
+ val password = Password(value, label, rich).apply { init?.invoke(this) }
+ this.add(password)
+ return password
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
index 9d5c8c49..953fec90 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
@@ -56,14 +56,16 @@ open class RichText(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.richText(
value: String? = null, label: String? = null, rich: Boolean = false, init: (RichText.() -> Unit)? = null
- ) {
- this.add(RichText(value, label, rich).apply { init?.invoke(this) })
+ ): RichText {
+ val richText = RichText(value, label, rich).apply { init?.invoke(this) }
+ this.add(richText)
+ return richText
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
index f802cc2a..9e6e61b0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
@@ -112,14 +112,16 @@ open class RichTextInput(value: String? = null, classes: Set<String> = setOf())
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.richTextInput(
value: String? = null, classes: Set<String> = setOf(), init: (RichTextInput.() -> Unit)? = null
- ) {
- this.add(RichTextInput(value, classes).apply { init?.invoke(this) })
+ ): RichTextInput {
+ val richTextInput = RichTextInput(value, classes).apply { init?.invoke(this) }
+ this.add(richTextInput)
+ return richTextInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
index 2878dc66..ac9d0d9b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
@@ -65,15 +65,17 @@ open class Text(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.text(
type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null,
label: String? = null, rich: Boolean = false, init: (Text.() -> Unit)? = null
- ) {
- this.add(Text(type, value, label, rich).apply { init?.invoke(this) })
+ ): Text {
+ val text = Text(type, value, label, rich).apply { init?.invoke(this) }
+ this.add(text)
+ return text
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
index e9575264..58f63028 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
@@ -74,15 +74,17 @@ open class TextArea(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.textArea(
cols: Int? = null, rows: Int? = null, value: String? = null,
label: String? = null, rich: Boolean = false, init: (TextArea.() -> Unit)? = null
- ) {
- this.add(TextArea(cols, rows, value, label, rich).apply { init?.invoke(this) })
+ ): TextArea {
+ val textArea = TextArea(cols, rows, value, label, rich).apply { init?.invoke(this) }
+ this.add(textArea)
+ return textArea
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
index 64e0f17d..8ee150e1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
@@ -84,15 +84,17 @@ open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? =
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.textAreaInput(
cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf(),
init: (TextAreaInput.() -> Unit)? = null
- ) {
- this.add(TextAreaInput(cols, rows, value, classes).apply { init?.invoke(this) })
+ ): TextAreaInput {
+ val textAreaInput = TextAreaInput(cols, rows, value, classes).apply { init?.invoke(this) }
+ this.add(textAreaInput)
+ return textAreaInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
index cc443aa5..a2bfcd0b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
@@ -88,15 +88,17 @@ open class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? =
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.textInput(
type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, classes: Set<String> = setOf(),
init: (TextInput.() -> Unit)? = null
- ) {
- this.add(TextInput(type, value, classes).apply { init?.invoke(this) })
+ ): TextInput {
+ val textInput = TextInput(type, value, classes).apply { init?.invoke(this) }
+ this.add(textInput)
+ return textInput
}
}
}