aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-02-02 01:10:24 +0100
committerRobert Jaros <rjaros@finn.pl>2020-02-02 01:10:24 +0100
commitfcc1282b15e0d382df22bb849454d6653291647e (patch)
treed73e6305a0a24c1d7b625542da84f6fa776ea0fb /kvision-modules
parent4591cd9da289356e40eb811efdfadfc65665c24d (diff)
downloadkvision-fcc1282b15e0d382df22bb849454d6653291647e.tar.gz
kvision-fcc1282b15e0d382df22bb849454d6653291647e.tar.bz2
kvision-fcc1282b15e0d382df22bb849454d6653291647e.zip
Change numeric parameters of the Spinner component to the type Number.
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt10
2 files changed, 13 insertions, 10 deletions
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
index b841b16c..69d9410b 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
@@ -48,7 +48,7 @@ import pl.treksoft.kvision.utils.SnOn
* @param rich determines if [label] can contain HTML code
*/
open class Spinner(
- value: Number? = null, name: String? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, name: String? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, val buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, label: String? = null,
rich: Boolean = false
@@ -206,7 +206,10 @@ open class Spinner(
return this
}
- @Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
+ @Deprecated(
+ "Use onEvent extension function instead.",
+ ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent")
+ )
override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
@Suppress("DEPRECATION")
input.setEventListener(block)
@@ -268,9 +271,9 @@ open class Spinner(
fun Container.spinner(
value: Number? = null,
name: String? = null,
- min: Int? = null,
- max: Int? = null,
- step: Double = DEFAULT_STEP,
+ min: Number? = null,
+ max: Number? = null,
+ step: Number = DEFAULT_STEP,
decimals: Int = 0,
buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE,
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
index c68df816..3a52fed2 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -52,7 +52,7 @@ enum class ForceType(internal val value: String) {
CEIL("ceil")
}
-internal const val DEFAULT_STEP = 1.0
+internal const val DEFAULT_STEP = 1
/**
* The basic component for spinner control.
@@ -70,7 +70,7 @@ internal const val DEFAULT_STEP = 1.0
*/
@Suppress("TooManyFunctions")
open class SpinnerInput(
- value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, val buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null,
classes: Set<String> = setOf()
@@ -210,8 +210,8 @@ open class SpinnerInput(
if (v != null && v.isNotEmpty()) {
this.value = v.toDoubleOrNull()
this.value?.let {
- if (min != null && it.toInt() < min ?: 0) this.value = min
- if (max != null && it.toInt() > max ?: 0) this.value = max
+ if (min != null && it.toDouble() < (min?.toDouble() ?: 0.0)) this.value = min
+ if (max != null && it.toDouble() > (max?.toDouble() ?: 0.0)) this.value = max
}
} else {
this.value = null
@@ -321,7 +321,7 @@ open class SpinnerInput(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.spinnerInput(
- value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, classes: Set<String> = setOf(),
init: (SpinnerInput.() -> Unit)? = null