aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/KVManager.kt3
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt20
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt2
5 files changed, 10 insertions, 19 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt
index f0438232..4ba518b5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt
@@ -41,6 +41,7 @@ external fun require(name: String): dynamic
/**
* Internal singleton object which initializes and configures KVision framework.
*/
+@Suppress("EmptyCatchBlock")
internal object KVManager {
internal const val AJAX_REQUEST_DELAY = 300
internal const val KVNULL = "#kvnull"
@@ -77,8 +78,6 @@ internal object KVManager {
require("ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js")
} catch (e: Throwable) {
}
- // private val bootstrapSelectAjaxI18n =
-// require("ajax-bootstrap-select/dist/js/locale/ajax-bootstrap-select.pl-PL.min.js")
private val trixCss = try {
require("trix/dist/trix.css")
} catch (e: Throwable) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
index c7eb5a22..aa29de34 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
@@ -133,7 +133,7 @@ open class RadioGroup(
}
private fun getDisabledFromChildren(): Boolean {
- return getChildren().filterIsInstance<Radio>().map { it.disabled }.firstOrNull() ?: false
+ return getChildren().filterIsInstance<Radio>().firstOrNull()?.disabled ?: false
}
private fun setDisabledToChildren(disabled: Boolean) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt
index dbada3dc..4a82ed5b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt
@@ -86,8 +86,8 @@ open class ResponsiveGridPanel(
* @return this container
*/
open fun add(child: Component, col: Int, row: Int, size: Int = 0, offset: Int = 0): ResponsiveGridPanel {
- val cRow = if (row < 0) 0 else row
- val cCol = if (col < 0) 0 else col
+ val cRow = maxOf(row, 0)
+ val cCol = maxOf(col, 0)
if (row > rows - 1) rows = cRow + 1
if (col > cols - 1) cols = cCol + 1
map.getOrPut(cRow, { mutableMapOf() })[cCol] = WidgetParam(child, size, offset)
@@ -107,16 +107,9 @@ open class ResponsiveGridPanel(
@Suppress("NestedBlockDepth")
override fun remove(child: Component): ResponsiveGridPanel {
- for (i in 0 until rows) {
- val row = map[i]
- if (row != null) {
- for (j in 0 until cols) {
- val wp = row[j]
- if (wp != null) {
- if (wp.widget == child) row.remove(j)
- }
- }
- }
+ map.values.forEach { row ->
+ row.filterValues { it.widget == child }
+ .forEach { (i, _) -> row.remove(i) }
}
refreshRowContainers()
return this
@@ -143,8 +136,7 @@ open class ResponsiveGridPanel(
val rowContainer = SimplePanel(setOf("row"))
val row = map[i]
if (row != null) {
- for (j in 0 until cols) {
- val wp = row[j]
+ (0 until cols).map { row[it] }.forEach { wp ->
if (auto) {
val widget = wp?.widget?.let {
WidgetWrapper(it, setOf("col-" + gridsize.size + "-" + num))
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
index 235c76ec..bac027fe 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
@@ -56,7 +56,7 @@ open class StackPanel(
}
override fun childrenVNodes(): Array<VNode> {
- return if (activeIndex >= 0 && activeIndex < children.size) {
+ return if (activeIndex in children.indices) {
arrayOf(children[activeIndex].renderVNode())
} else {
arrayOf()
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
index 4572036d..1ac69b7b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
@@ -51,7 +51,7 @@ open class TabPanel(classes: Set<String> = setOf(), init: (TabPanel.() -> Unit)?
nav.children.forEach {
it.removeCssClass("active")
}
- if (content.activeIndex >= 0 && content.activeIndex <= nav.children.size) {
+ if (content.activeIndex in nav.children.indices) {
nav.children[content.activeIndex].addCssClass("active")
}
}