aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap-select
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
commit736b80835f67c9c34657074ebcfbe0752bef1c18 (patch)
tree82d1e18a9ec07692dfe5dd31f470b842a9950a89 /kvision-modules/kvision-bootstrap-select
parent53b325d52208bfd44ba6a524ce3dda5379aed699 (diff)
downloadkvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.gz
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.bz2
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.zip
Move DSL builder functions out of the companion objects (#93)
Diffstat (limited to 'kvision-modules/kvision-bootstrap-select')
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt30
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt31
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt58
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt111
4 files changed, 111 insertions, 119 deletions
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
index 4b2505d2..ea98e369 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
@@ -266,20 +266,20 @@ open class Select(
companion object {
internal var counter = 0
-
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.select(
- options: List<StringPair>? = null, value: String? = null, name: String? = null,
- multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null,
- rich: Boolean = false, init: (Select.() -> Unit)? = null
- ): Select {
- val select = Select(options, value, name, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) }
- this.add(select)
- return select
- }
}
}
+
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.select(
+ options: List<StringPair>? = null, value: String? = null, name: String? = null,
+ multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null,
+ rich: Boolean = false, init: (Select.() -> Unit)? = null
+): Select {
+ val select = Select(options, value, name, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) }
+ this.add(select)
+ return select
+}
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
index 84eccaf7..b515ea3e 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
@@ -354,22 +354,19 @@ open class SelectInput(
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.selectInput(
- options: List<StringPair>? = null, value: String? = null,
- multiple: Boolean = false, ajaxOptions: AjaxOptions? = null,
- classes: Set<String> = setOf(), init: (SelectInput.() -> Unit)? = null
- ): SelectInput {
- val selectInput = SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) }
- this.add(selectInput)
- return selectInput
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.selectInput(
+ options: List<StringPair>? = null, value: String? = null,
+ multiple: Boolean = false, ajaxOptions: AjaxOptions? = null,
+ classes: Set<String> = setOf(), init: (SelectInput.() -> Unit)? = null
+): SelectInput {
+ val selectInput = SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) }
+ this.add(selectInput)
+ return selectInput
}
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
index 3f07a9bf..7893f891 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt
@@ -88,36 +88,34 @@ open class SelectOptGroup(
}
return sn
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Select.selectOptGroup(
- label: String, options: List<StringPair>? = null, maxOptions: Int? = null,
- disabled: Boolean = false, classes: Set<String> = setOf(), init: (SelectOptGroup.() -> Unit)? = null
- ): SelectOptGroup {
- val selectOptGroup =
- SelectOptGroup(label, options, maxOptions, disabled, classes).apply { init?.invoke(this) }
- this.add(selectOptGroup)
- return selectOptGroup
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Select.selectOptGroup(
+ label: String, options: List<StringPair>? = null, maxOptions: Int? = null,
+ disabled: Boolean = false, classes: Set<String> = setOf(), init: (SelectOptGroup.() -> Unit)? = null
+): SelectOptGroup {
+ val selectOptGroup =
+ SelectOptGroup(label, options, maxOptions, disabled, classes).apply { init?.invoke(this) }
+ this.add(selectOptGroup)
+ return selectOptGroup
+}
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun SelectInput.selectOptGroup(
- label: String, options: List<StringPair>? = null, maxOptions: Int? = null,
- disabled: Boolean = false, classes: Set<String> = setOf(), init: (SelectOptGroup.() -> Unit)? = null
- ): SelectOptGroup {
- val selectOptGroup =
- SelectOptGroup(label, options, maxOptions, disabled, classes).apply { init?.invoke(this) }
- this.add(selectOptGroup)
- return selectOptGroup
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun SelectInput.selectOptGroup(
+ label: String, options: List<StringPair>? = null, maxOptions: Int? = null,
+ disabled: Boolean = false, classes: Set<String> = setOf(), init: (SelectOptGroup.() -> Unit)? = null
+): SelectOptGroup {
+ val selectOptGroup =
+ SelectOptGroup(label, options, maxOptions, disabled, classes).apply { init?.invoke(this) }
+ this.add(selectOptGroup)
+ return selectOptGroup
}
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
index 91c269a8..a9c7eda5 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt
@@ -104,67 +104,64 @@ open class SelectOption(
}
return sn
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Select.selectOption(
- value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
- divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
- classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
- ): SelectOption {
- val selectOption =
- SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
- init?.invoke(
- this
- )
- }
- this.add(selectOption)
- return selectOption
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Select.selectOption(
+ value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
+ divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
+ classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
+): SelectOption {
+ val selectOption =
+ SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
+ init?.invoke(
+ this
+ )
}
+ this.add(selectOption)
+ return selectOption
+}
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun SelectInput.selectOption(
- value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
- divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
- classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
- ): SelectOption {
- val selectOption =
- SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
- init?.invoke(
- this
- )
- }
- this.add(selectOption)
- return selectOption
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun SelectInput.selectOption(
+ value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
+ divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
+ classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
+): SelectOption {
+ val selectOption =
+ SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
+ init?.invoke(
+ this
+ )
}
+ this.add(selectOption)
+ return selectOption
+}
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun SelectOptGroup.selectOption(
- value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
- divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
- classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
- ): SelectOption {
- val selectOption =
- SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
- init?.invoke(
- this
- )
- }
- this.add(selectOption)
- return selectOption
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun SelectOptGroup.selectOption(
+ value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null,
+ divider: Boolean = false, disabled: Boolean = false, selected: Boolean = false,
+ classes: Set<String> = setOf(), init: (SelectOption.() -> Unit)? = null
+): SelectOption {
+ val selectOption =
+ SelectOption(value, label, subtext, icon, divider, disabled, selected, classes).apply {
+ init?.invoke(
+ this
+ )
}
-
- }
+ this.add(selectOption)
+ return selectOption
}