aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-09-30 12:50:04 +0200
committerRobert Jaros <rjaros@finn.pl>2017-09-30 12:50:04 +0200
commitef4d83ee13289761a014f884ee83688038e7b497 (patch)
tree7cf00eba1327898660584285c814aef4226c3ae7 /src/main/kotlin/pl/treksoft/kvision
parent4a62542e4dcc47c337885c74704500b67c15d02d (diff)
downloadkvision-ef4d83ee13289761a014f884ee83688038e7b497.tar.gz
kvision-ef4d83ee13289761a014f884ee83688038e7b497.tar.bz2
kvision-ef4d83ee13289761a014f884ee83688038e7b497.zip
Unit tests
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Root.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/tabs/Tabs.kt8
4 files changed, 14 insertions, 6 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
index e75167e1..aa7d7a4a 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
@@ -22,7 +22,7 @@ object KVManager {
private val sdPatch = Snabbdom.init(arrayOf(classModule, attributesModule, propsModule, styleModule,
eventListenersModule, datasetModule))
private val sdVirtualize = require("snabbdom-virtualize/strings").default
- private val splitCss = require("./css/style.css")
+ private val styleCss = require("./css/style.css")
internal fun patch(id: String, vnode: VNode): VNode {
val container = document.getElementById(id)
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Root.kt b/src/main/kotlin/pl/treksoft/kvision/core/Root.kt
index 82030249..52424f0e 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Root.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Root.kt
@@ -18,16 +18,16 @@ class Root(id: String, private val fixed: Boolean = false) : Container() {
return kvh("div#" + id, childrenVNodes() + modalsVNodes())
}
- private fun modalsVNodes(): Array<VNode> {
- return modals.filter { it.visible }.map { it.render() }.toTypedArray()
- }
-
internal fun addModal(modal: Modal) {
modals.add(modal)
modal.parent = this
refresh()
}
+ private fun modalsVNodes(): Array<VNode> {
+ return modals.filter { it.visible }.map { it.render() }.toTypedArray()
+ }
+
override fun getSnClass(): List<StringBoolPair> {
val css = if (!fixed) "container-fluid" else "container"
return super.getSnClass() + (css to true)
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
index 24429d42..372098b8 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt
@@ -23,12 +23,14 @@ open class StackPanel(private val activateLast: Boolean = true,
override fun add(child: Widget): Container {
super.add(child)
if (activateLast) activeIndex = children.size - 1
+ else if (activeIndex == -1) activeIndex = 0
return this
}
override fun addAll(children: List<Widget>): Container {
super.addAll(children)
if (activateLast) activeIndex = this.children.size - 1
+ else if (activeIndex == -1) activeIndex = 0
return this
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/tabs/Tabs.kt b/src/main/kotlin/pl/treksoft/kvision/tabs/Tabs.kt
index b21b1713..773f341a 100644
--- a/src/main/kotlin/pl/treksoft/kvision/tabs/Tabs.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/tabs/Tabs.kt
@@ -11,7 +11,7 @@ import pl.treksoft.kvision.panel.StackPanel
open class Tabs : Container(setOf()) {
private var nav = Tag(TAG.UL, classes = setOf("nav", "nav-tabs"))
private var content = StackPanel(false)
- private var activeIndex
+ var activeIndex
get() = content.activeIndex
set(value) {
content.activeIndex = value
@@ -47,4 +47,10 @@ open class Tabs : Container(setOf()) {
return this
}
+ open fun removeTab(index: Int): Tabs {
+ nav.removeAt(index)
+ content.removeAt(index)
+ activeIndex = content.activeIndex
+ return this
+ }
}