diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-04-04 12:41:48 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-04-04 12:41:48 +0200 |
commit | 2011c50d03e4b09d968707a142e57891a3d8c5fe (patch) | |
tree | 630f1ec5cb1b323cd8d54893def024b9f1792a14 /src/main/kotlin/pl/treksoft/kvision/modal | |
parent | a195fa82f8b4f75cc4fc2dc2a2d578ec45cf4323 (diff) | |
download | kvision-2011c50d03e4b09d968707a142e57891a3d8c5fe.tar.gz kvision-2011c50d03e4b09d968707a142e57891a3d8c5fe.tar.bz2 kvision-2011c50d03e4b09d968707a142e57891a3d8c5fe.zip |
Fix modals rendering.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/modal')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index a0456e7e..5f911539 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.modal import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Component +import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget @@ -60,6 +61,8 @@ open class Modal( classes: Set<String> = setOf(), init: (Modal.() -> Unit)? = null ) : SimplePanel(classes) { + override var parent: Container? = Root.getFirstRoot() + /** * Window caption text. */ @@ -125,13 +128,7 @@ open class Modal( content.add(header) content.add(body) content.add(footer) - val root = Root.getLastRoot() - if (root != null) { - @Suppress("LeakingThis") - root.addModal(this) - } else { - println("At least one Root object is required to create a modal!") - } + modals.add(this) @Suppress("LeakingThis") init?.invoke(this) } @@ -258,6 +255,23 @@ open class Modal( private fun hideInternal() { getElementJQueryD()?.modal("hide") } + + override fun clearParent(): Widget { + this.parent = null + return this + } + + override fun getRoot(): Root? { + return this.parent?.getRoot() + } + + override fun dispose() { + modals.remove(this) + } + + companion object { + internal var modals = mutableListOf<Modal>() + } } /** |