aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@users.noreply.github.com>2020-04-29 10:56:06 +0200
committerGitHub <noreply@github.com>2020-04-29 10:56:06 +0200
commit14c3ebc7f4aa9756655bbfd2bf5ed00f2ae11012 (patch)
tree82ad7ad34871c259658398bfa46932fa8ea1e504 /kvision-modules
parentd45d14cbe62fff32c9f1c44f90e6bf66ddc2304e (diff)
parent9fbc710662e398199ba0082cbd3add9aa22c16a3 (diff)
downloadkvision-14c3ebc7f4aa9756655bbfd2bf5ed00f2ae11012.tar.gz
kvision-14c3ebc7f4aa9756655bbfd2bf5ed00f2ae11012.tar.bz2
kvision-14c3ebc7f4aa9756655bbfd2bf5ed00f2ae11012.zip
Merge pull request #151 from bmalkow/master
Add property to scrolling long content in Modal
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-bootstrap-dialog/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt4
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt23
2 files changed, 22 insertions, 5 deletions
diff --git a/kvision-modules/kvision-bootstrap-dialog/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt b/kvision-modules/kvision-bootstrap-dialog/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt
index 511dfd00..45b3a008 100644
--- a/kvision-modules/kvision-bootstrap-dialog/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt
+++ b/kvision-modules/kvision-bootstrap-dialog/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt
@@ -40,9 +40,9 @@ import kotlin.coroutines.resume
*/
open class Dialog<R>(
caption: String? = null, closeButton: Boolean = true,
- size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, escape: Boolean = true,
+ size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, scrollable: Boolean = false, escape: Boolean = true,
classes: Set<String> = setOf(), init: (Dialog<R>.() -> Unit)? = null
-) : Modal(caption, closeButton, size, animation, escape, centered, classes) {
+) : Modal(caption, closeButton, size, animation, escape, centered, scrollable, classes) {
internal var resultCallback: ((R?) -> Unit)? = null
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
index baf1d4e0..afc5f5fd 100644
--- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
+++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt
@@ -60,7 +60,7 @@ enum class ModalSize(val className: String) {
@Suppress("TooManyFunctions")
open class Modal(
caption: String? = null, closeButton: Boolean = true,
- size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, private val escape: Boolean = true,
+ size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, scrollable: Boolean = false, private val escape: Boolean = true,
classes: Set<String> = setOf(), init: (Modal.() -> Unit)? = null
) : SimplePanel(classes) {
@@ -105,7 +105,16 @@ open class Modal(
dialog.centered = value
}
- private val dialog = ModalDialog(size, centered)
+ /**
+ * Determines if modal body is scrollable.
+ */
+ var scrollable
+ get() = dialog.scrollable
+ set(value) {
+ dialog.scrollable = value
+ }
+
+ private val dialog = ModalDialog(size, centered, scrollable)
private val header = SimplePanel(setOf("modal-header"))
/**
* @suppress
@@ -284,7 +293,7 @@ open class Modal(
* @param size modal window size
* @param centered determines if modal dialog is vertically centered
*/
-internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : SimplePanel(setOf("modal-dialog")) {
+internal class ModalDialog(size: ModalSize?, centered: Boolean = false, scrollable: Boolean = false) : SimplePanel(setOf("modal-dialog")) {
/**
* Modal window size.
@@ -296,6 +305,11 @@ internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : Simple
*/
var centered by refreshOnUpdate(centered)
+ /**
+ * Determines if content is scrollable.
+ */
+ var scrollable by refreshOnUpdate(scrollable)
+
override fun getSnClass(): List<StringBoolPair> {
val cl = super.getSnClass().toMutableList()
size?.let {
@@ -304,6 +318,9 @@ internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : Simple
if (centered) {
cl.add("modal-dialog-centered" to true)
}
+ if (scrollable) {
+ cl.add("modal-dialog-scrollable" to true)
+ }
return cl
}
}