aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap-select/src/main
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-25 15:08:38 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-25 15:08:38 +0200
commita990385dd3f2dbac4807b7a9498271efb3519c0d (patch)
treee5b2e4a550cefea0541c798a243a9dcec7343168 /kvision-modules/kvision-bootstrap-select/src/main
parent888a25415f4f309f66d72a698b40b0f7043e9ee7 (diff)
downloadkvision-a990385dd3f2dbac4807b7a9498271efb3519c0d.tar.gz
kvision-a990385dd3f2dbac4807b7a9498271efb3519c0d.tar.bz2
kvision-a990385dd3f2dbac4807b7a9498271efb3519c0d.zip
Now dropdown align option for Select and RemoteSelect components.
Diffstat (limited to 'kvision-modules/kvision-bootstrap-select/src/main')
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt8
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt24
2 files changed, 32 insertions, 0 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 ea98e369..8373dee7 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
@@ -135,6 +135,14 @@ open class Select(
input.selectWidthType = value
}
/**
+ * The dropdown align of the select control.
+ */
+ var dropdownAlign
+ get() = input.dropdownAlign
+ set(value) {
+ input.dropdownAlign = value
+ }
+ /**
* Determines if an empty option is automatically generated.
*/
var emptyOption
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 b515ea3e..31ae5125 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
@@ -45,6 +45,15 @@ enum class SelectWidthType(internal val value: String) {
}
/**
+ * Select dropdown align. See [Bootstrap Select width](http://silviomoreto.github.io/bootstrap-select/examples/#width).
+ */
+enum class SelectDropdownAlign {
+ AUTO,
+ LEFT,
+ RIGHT
+}
+
+/**
* The basic component for Select control.
*
* The select control can be populated directly from *options* parameter or manually by adding
@@ -114,6 +123,10 @@ open class SelectInput(
*/
var selectWidthType: SelectWidthType? by refreshOnUpdate()
/**
+ * The dropdown align of the select control.
+ */
+ var dropdownAlign by refreshOnUpdate(SelectDropdownAlign.LEFT)
+ /**
* Determines if an empty option is automatically generated.
*/
var emptyOption by refreshOnUpdate(false) { setChildrenFromOptions() }
@@ -291,6 +304,15 @@ open class SelectInput(
} ?: selectWidth?.let {
sn.add("data-width" to it.asString())
}
+ when (dropdownAlign) {
+ SelectDropdownAlign.RIGHT -> {
+ sn.add("data-dropdown-align-right" to "true")
+ }
+ SelectDropdownAlign.AUTO -> {
+ sn.add("data-dropdown-align-right" to "auto")
+ }
+ else -> {}
+ }
return sn
}
@@ -338,6 +360,8 @@ open class SelectInput(
getElementJQueryD()?.selectpicker("val", it)
}
} ?: getElementJQueryD()?.selectpicker("val", null)
+ } else if (value == null) {
+ getElementJQueryD()?.selectpicker("val", null)
}
}