diff options
-rw-r--r-- | kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt index d75d10df..44c0a243 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt @@ -146,6 +146,7 @@ open class TabPanel( * @param route JavaScript route to activate given child * @return current container */ + @Suppress("UnsafeCastFromDynamic") open fun addTab( title: String, panel: Component, icon: String? = null, image: ResString? = null, closable: Boolean = false, route: String? = null @@ -181,6 +182,9 @@ open class TabPanel( e.preventDefault() if (route != null) { routing.navigate(route) + } else { + e.asDynamic().data = activeIndex + this@TabPanel.dispatchEvent("tabChange", obj { detail = e }) } } } @@ -194,8 +198,10 @@ open class TabPanel( if (route != null) { routing.on( route, - { _ -> activeIndex = this@TabPanel.content.getChildren().indexOf(childrenMap[currentIndex]) }) - .resolve() + { _ -> + activeIndex = this@TabPanel.content.getChildren().indexOf(childrenMap[currentIndex]) + this@TabPanel.dispatchEvent("tabChange", obj { detail = obj { data = activeIndex } }) + }).resolve() } return this } @@ -210,6 +216,7 @@ open class TabPanel( } content.remove(content.getChildren()[index]) activeIndex = content.activeIndex + this@TabPanel.dispatchEvent("tabChange", obj { detail = obj { data = activeIndex } }) return this } diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt index 583dd74c..00d7e59a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt @@ -133,6 +133,7 @@ interface BtOn : On { var tabulatorDataLoading: ((KvEvent) -> Unit)? var tabulatorDataLoaded: ((KvEvent) -> Unit)? var tabulatorDataEdited: ((KvEvent) -> Unit)? + var tabChange: ((KvEvent) -> Unit)? var tabClosing: ((KvEvent) -> Unit)? var tabClosed: ((KvEvent) -> Unit)? } |