From c5c29491437f1b9de2ab6bff05a1455b42edfcfc Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 12 Nov 2017 03:26:57 +0100 Subject: DateTimePicker components --- src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 55 +++++ .../kotlin/pl/treksoft/kvision/core/KVManager.kt | 3 + .../kotlin/pl/treksoft/kvision/form/FormField.kt | 7 + .../pl/treksoft/kvision/form/text/AbstractText.kt | 12 +- .../pl/treksoft/kvision/form/time/DateTime.kt | 142 +++++++++++++ .../pl/treksoft/kvision/form/time/DateTimeInput.kt | 226 +++++++++++++++++++++ .../kotlin/pl/treksoft/kvision/snabbdom/Types.kt | 3 + src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt | 12 ++ 8 files changed, 459 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt (limited to 'src/main/kotlin/pl/treksoft/kvision') diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index 084b60d6..8e7fcb3b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -21,6 +21,8 @@ import pl.treksoft.kvision.form.text.Text import pl.treksoft.kvision.form.text.TextArea import pl.treksoft.kvision.form.text.TextAreaInput import pl.treksoft.kvision.form.text.TextInput +import pl.treksoft.kvision.form.time.DateTime +import pl.treksoft.kvision.form.time.DateTimeInput import pl.treksoft.kvision.html.* import pl.treksoft.kvision.html.TAG.DIV import pl.treksoft.kvision.html.TAG.H1 @@ -32,6 +34,8 @@ import pl.treksoft.kvision.routing.routing import pl.treksoft.kvision.snabbdom.obj import pl.treksoft.kvision.utils.perc import pl.treksoft.kvision.utils.px +import pl.treksoft.kvision.utils.toDateF +import kotlin.js.Date class Showcase : ApplicationBase() { @@ -237,6 +241,57 @@ class Showcase : ApplicationBase() { } root.add(mbuttons9) + val date = DateTimeInput().apply { + placeholder = "Wprowadź datę" + size = INPUTSIZE.LARGE + todayBtn = true + showMeridian = true + daysOfWeekDisabled = arrayOf(0, 6) + + } + root.add(date) + + val date2 = DateTimeInput(Date(), format = "DD-MM-YY").apply { + disabled = true + } + root.add(date2) + + val date3 = DateTimeInput(Date(), format = "DD-MM-YYYY hh:mm A").apply { + readonly = true + showMeridian = true + } + root.add(date3) + + val date4 = DateTime(Date(), format = "HH:mm", label = "Wprowadź datę wpływu") + date4.setEventListener { + showBsDateTime = { + println("show dt") + } + hideBsDateTime = { + println("hide dt") + } + } + root.add(date4) + + val mbuttons10 = Button("Sprawdz daty").setEventListener