From c28f003eb5c588c5942b86521991c46374ad190a Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 4 Nov 2017 00:06:10 +0100 Subject: Small fixes for select component --- src/main/kotlin/pl/treksoft/kvision/form/SelectInput.kt | 1 + src/main/kotlin/pl/treksoft/kvision/form/SelectOptGroup.kt | 2 +- src/main/kotlin/pl/treksoft/kvision/form/SelectOption.kt | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/SelectInput.kt index 7ef29754..bd67868d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/SelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/SelectInput.kt @@ -144,6 +144,7 @@ class SelectInput(options: List? = null, override var value: String? return cl } + @Suppress("ComplexMethod") override fun getSnAttrs(): List { val sn = super.getSnAttrs().toMutableList() name?.let { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/SelectOptGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/SelectOptGroup.kt index 22483777..41eb951e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/SelectOptGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/SelectOptGroup.kt @@ -57,4 +57,4 @@ class SelectOptGroup(label: String, options: List? = null, maxOption } return sn } -} \ No newline at end of file +} diff --git a/src/main/kotlin/pl/treksoft/kvision/form/SelectOption.kt b/src/main/kotlin/pl/treksoft/kvision/form/SelectOption.kt index 48412e17..f3be295c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/SelectOption.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/SelectOption.kt @@ -45,15 +45,19 @@ open class SelectOption(value: String? = null, label: String? = null, subtext: S } override fun render(): VNode { - return kvh("option", arrayOf(label ?: value)) + return if (!divider) { + kvh("option", arrayOf(label ?: value)) + } else { + kvh("option") + } } override fun getSnAttrs(): List { val sn = super.getSnAttrs().toMutableList() - value?.let { - sn.add("value" to it) - } if (!divider) { + value?.let { + sn.add("value" to it) + } subtext?.let { sn.add("data-subtext" to it) } -- cgit