aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/select
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-05-09 23:53:57 +0200
committerRobert Jaros <rjaros@finn.pl>2020-05-09 23:53:57 +0200
commit134cb687c4e05fd81a03b682505f9fb9d741a8d7 (patch)
treef9f41f28c01dc29d1d4fdd576cc9b21958fd9c3b /src/main/kotlin/pl/treksoft/kvision/form/select
parent4a2aa49e0e561c1bc25aa962449fa2fcce9207ba (diff)
downloadkvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.gz
kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.bz2
kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.zip
Add new className parameter to all DSL builder functions.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/select')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt15
2 files changed, 14 insertions, 3 deletions
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 4d47a239..e797e050 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelect.kt
@@ -116,7 +116,7 @@ open class SimpleSelect(
this.id = idc
this.name = name
}
- final override val flabel: FieldLabel = FieldLabel(idc, label, rich)
+ final override val flabel: FieldLabel = FieldLabel(idc, label, rich, setOf("control-label"))
final override val invalidFeedback: InvalidFeedback = InvalidFeedback().apply { visible = false }
init {
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 bc99f514..63eb98b5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt
@@ -31,6 +31,7 @@ import pl.treksoft.kvision.form.ValidationStatus
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
import pl.treksoft.kvision.panel.SimplePanel
+import pl.treksoft.kvision.utils.set
internal const val KVNULL = "#kvnull"
@@ -57,6 +58,7 @@ open class SimpleSelectInput(
* Text input value.
*/
var value by refreshOnUpdate(value) { refreshState() }
+
/**
* The value of the selected child option.
*
@@ -64,26 +66,32 @@ open class SimpleSelectInput(
* bound to the select component.
*/
var startValue by refreshOnUpdate(value) { this.value = it; selectOption() }
+
/**
* The name attribute of the generated HTML input element.
*/
override var name: String? by refreshOnUpdate()
+
/**
* Determines if the field is disabled.
*/
override var disabled by refreshOnUpdate(false)
+
/**
* Determines if the text input is automatically focused.
*/
var autofocus: Boolean? by refreshOnUpdate()
+
/**
* Determines if an empty option is automatically generated.
*/
var emptyOption by refreshOnUpdate(emptyOption) { setChildrenFromOptions() }
+
/**
* The size of the input.
*/
override var size: InputSize? by refreshOnUpdate()
+
/**
* The validation status of the input.
*/
@@ -208,9 +216,12 @@ open class SimpleSelectInput(
*/
fun Container.simpleSelectInput(
options: List<StringPair>? = null, value: String? = null, emptyOption: Boolean = false,
- classes: Set<String> = setOf(), init: (SimpleSelectInput.() -> Unit)? = null
+ classes: Set<String>? = null,
+ className: String? = null,
+ init: (SimpleSelectInput.() -> Unit)? = null
): SimpleSelectInput {
- val simpleSelectInput = SimpleSelectInput(options, value, emptyOption, classes).apply { init?.invoke(this) }
+ val simpleSelectInput =
+ SimpleSelectInput(options, value, emptyOption, classes ?: className.set).apply { init?.invoke(this) }
this.add(simpleSelectInput)
return simpleSelectInput
}