From bcc5292dd95e5824da41a19bfbf64ebc25d79102 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 16 Jan 2018 00:13:54 +0100 Subject: Spinner form controls Unit tests --- src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 29 +++ .../kotlin/pl/treksoft/kvision/core/KVManager.kt | 2 + src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 21 +- .../pl/treksoft/kvision/form/spinner/Spinner.kt | 148 +++++++++++++ .../treksoft/kvision/form/spinner/SpinnerInput.kt | 242 +++++++++++++++++++++ .../kvision/form/text/AbstractTextInput.kt | 5 + .../kotlin/pl/treksoft/kvision/snabbdom/Types.kt | 2 + 7 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt (limited to 'src/main/kotlin/pl') diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index 82651b71..a27fae2d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -20,6 +20,9 @@ import pl.treksoft.kvision.form.select.Select import pl.treksoft.kvision.form.select.SelectInput import pl.treksoft.kvision.form.select.SelectOptGroup import pl.treksoft.kvision.form.select.SelectOption +import pl.treksoft.kvision.form.spinner.FORCETYPE +import pl.treksoft.kvision.form.spinner.Spinner +import pl.treksoft.kvision.form.spinner.SpinnerInput import pl.treksoft.kvision.form.string import pl.treksoft.kvision.form.text.Password import pl.treksoft.kvision.form.text.RichText @@ -414,6 +417,7 @@ class Showcase : ApplicationBase() { val checkbox: Boolean by map val radio: Boolean by map val select: String? by map + val spinner: Double? by map } val formPanel = FormPanel() { @@ -436,6 +440,7 @@ class Showcase : ApplicationBase() { // selectWidthType = SELECTWIDTHTYPE.FIT emptyOption = true }, required = true) + add("spinner", Spinner(label = "Spinner"), required = true) validator = { var result = it["text"] == it["textarea"] @@ -448,14 +453,38 @@ class Showcase : ApplicationBase() { validatorMessage = { "Pole Tekst i Obszar muszą być takie same!" } } root.add(formPanel) + val spinner = SpinnerInput(15.05, min = -100000, max = 100000, decimals = 4, forceType = FORCETYPE.ROUND, step = 0.0001).apply { + size = INPUTSIZE.LARGE + } + val ttt = TextInput(value = "abc").apply { + size = INPUTSIZE.LARGE + } + spinner.setEventListener { + onMinBsSpinner = { e -> + console.log(e) + } + onMaxBsSpinner = { e -> + console.log(e) + } + } val formButton = Button("Pokaż dane").setEventListener