diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form')
26 files changed, 130 insertions, 76 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt index 9e9671ed..a28245d6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt @@ -4,9 +4,13 @@ import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.snabbdom.StringPair -open class FieldLabel(internal val forId: String, text: String? = null, rich: Boolean = false, - classes: Set<String> = setOf("control-label")) : Tag(TAG.LABEL, - text, rich, classes = classes) { +open class FieldLabel( + internal val forId: String, text: String? = null, rich: Boolean = false, + classes: Set<String> = setOf("control-label") +) : Tag( + TAG.LABEL, + text, rich, classes = classes +) { override fun getSnAttrs(): List<StringPair> { return super.getSnAttrs() + ("for" to forId) diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt index 337152e3..91773bb6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt @@ -2,9 +2,11 @@ package pl.treksoft.kvision.form import kotlin.js.Date -data class FieldParams<in F : FormControl>(val required: Boolean = false, - val validatorMessage: ((F) -> String?)? = null, - val validator: ((F) -> Boolean?)? = null) +data class FieldParams<in F : FormControl>( + val required: Boolean = false, + val validatorMessage: ((F) -> String?)? = null, + val validator: ((F) -> Boolean?)? = null +) open class Form<K>(private val panel: FormPanel<K>? = null, private val modelFactory: (Map<String, Any?>) -> K) { @@ -13,9 +15,11 @@ open class Form<K>(private val panel: FormPanel<K>? = null, private val modelFac internal var validatorMessage: ((Form<K>) -> String?)? = null internal var validator: ((Form<K>) -> Boolean?)? = null - open fun <C : FormControl> add(key: String, control: C, required: Boolean = false, - validatorMessage: ((C) -> String?)? = null, - validator: ((C) -> Boolean?)? = null): Form<K> { + open fun <C : FormControl> add( + key: String, control: C, required: Boolean = false, + validatorMessage: ((C) -> String?)? = null, + validator: ((C) -> Boolean?)? = null + ): Form<K> { this.fields.put(key, control) this.fieldsParams.put(key, FieldParams(required, validatorMessage, validator)) return this diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt index 65015f3f..31ab3ced 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt @@ -13,8 +13,10 @@ enum class FORMTYPE(val formType: String) { HORIZONTAL("form-horizontal") } -open class FormPanel<K>(private val type: FORMTYPE? = null, classes: Set<String> = setOf(), - modelFactory: (Map<String, Any?>) -> K) : SimplePanel(classes) { +open class FormPanel<K>( + private val type: FORMTYPE? = null, classes: Set<String> = setOf(), + modelFactory: (Map<String, Any?>) -> K +) : SimplePanel(classes) { var validatorMessage get() = form.validatorMessage @@ -58,9 +60,11 @@ open class FormPanel<K>(private val type: FORMTYPE? = null, classes: Set<String> return cl } - open fun <C : FormControl> add(key: String, control: C, required: Boolean = false, - validatorMessage: ((C) -> String?)? = null, - validator: ((C) -> Boolean?)? = null): FormPanel<K> { + open fun <C : FormControl> add( + key: String, control: C, required: Boolean = false, + validatorMessage: ((C) -> String?)? = null, + validator: ((C) -> Boolean?)? = null + ): FormPanel<K> { if (type == FORMTYPE.HORIZONTAL) { if (control is CheckBox || control is Radio) { control.addCssClass("col-sm-offset-2") diff --git a/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt b/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt index 44b2e7b0..dcfd185e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt @@ -3,5 +3,7 @@ package pl.treksoft.kvision.form import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag -open class HelpBlock(text: String? = null, rich: Boolean = false) : Tag(TAG.SPAN, text, rich, - classes = setOf("help-block", "small")) +open class HelpBlock(text: String? = null, rich: Boolean = false) : Tag( + TAG.SPAN, text, rich, + classes = setOf("help-block", "small") +) diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt index 62403f8a..4faee7e7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -17,8 +17,10 @@ enum class CHECKBOXSTYLE(val className: String) { DANGER("checkbox-danger"), } -open class CheckBox(value: Boolean = false, label: String? = null, - rich: Boolean = false) : SimplePanel(setOf("checkbox")), BoolFormControl { +open class CheckBox( + value: Boolean = false, label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("checkbox")), BoolFormControl { override var value get() = input.value @@ -72,8 +74,10 @@ open class CheckBox(value: Boolean = false, label: String? = null, } private val idc = "kv_form_checkbox_" + counter - final override val input: CheckInput = CheckInput(CHECKINPUTTYPE.CHECKBOX, value, - setOf("styled")).apply { id = idc } + final override val input: CheckInput = CheckInput( + CHECKINPUTTYPE.CHECKBOX, value, + setOf("styled") + ).apply { id = idc } final override val flabel: FieldLabel = FieldLabel(idc, label, rich, classes = setOf()) final override val validationInfo: HelpBlock = HelpBlock().apply { visible = false } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt index a2ebd06d..a3ccd126 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt @@ -11,8 +11,10 @@ enum class CHECKINPUTTYPE(val type: String) { RADIO("radio") } -open class CheckInput(type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false, - classes: Set<String> = setOf()) : Widget(classes) { +open class CheckInput( + type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false, + classes: Set<String> = setOf() +) : Widget(classes) { init { this.setInternalEventListener<CheckInput> { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt index 696e2264..1ec63f60 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -17,8 +17,10 @@ enum class RADIOSTYLE(val className: String) { DANGER("radio-danger"), } -open class Radio(value: Boolean = false, extraValue: String? = null, label: String? = null, - rich: Boolean = false) : SimplePanel(), BoolFormControl { +open class Radio( + value: Boolean = false, extraValue: String? = null, label: String? = null, + rich: Boolean = false +) : SimplePanel(), BoolFormControl { override var value get() = input.value diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt index df99dedf..fdf0e6a9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -10,9 +10,11 @@ import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.StringBoolPair import pl.treksoft.kvision.snabbdom.StringPair -open class RadioGroup(options: List<StringPair>? = null, value: String? = null, inline: Boolean = false, - label: String? = null, - rich: Boolean = false) : SimplePanel(setOf("form-group")), StringFormControl { +open class RadioGroup( + options: List<StringPair>? = null, value: String? = null, inline: Boolean = false, + label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("form-group")), StringFormControl { internal var options = options set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt index d86e6899..0cff73db 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt @@ -17,12 +17,14 @@ enum class DataType(val type: String) { SCRIPT("script") } -data class AjaxOptions(val url: String, val processData: (dynamic) -> dynamic, - val processParams: dynamic = null, val httpType: HttpType = HttpType.GET, - val dataType: DataType = DataType.JSON, val minLength: Int = 0, - val cache: Boolean = true, val clearOnEmpty: Boolean = true, val clearOnError: Boolean = true, - val emptyRequest: Boolean = false, val preserveSelected: Boolean = true, - val requestDelay: Int = AJAX_REQUEST_DELAY, val restoreOnError: Boolean = false) +data class AjaxOptions( + val url: String, val processData: (dynamic) -> dynamic, + val processParams: dynamic = null, val httpType: HttpType = HttpType.GET, + val dataType: DataType = DataType.JSON, val minLength: Int = 0, + val cache: Boolean = true, val clearOnEmpty: Boolean = true, val clearOnError: Boolean = true, + val emptyRequest: Boolean = false, val preserveSelected: Boolean = true, + val requestDelay: Int = AJAX_REQUEST_DELAY, val restoreOnError: Boolean = false +) fun AjaxOptions.toJs(emptyOption: Boolean): dynamic { val procData = { data: dynamic -> diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt index 2d750683..5f10191f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt @@ -11,9 +11,11 @@ import pl.treksoft.kvision.snabbdom.StringBoolPair import pl.treksoft.kvision.snabbdom.StringPair @Suppress("TooManyFunctions") -open class Select(options: List<StringPair>? = null, value: String? = null, - multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null, - rich: Boolean = false) : SimplePanel(setOf("form-group")), StringFormControl { +open class Select( + options: List<StringPair>? = null, value: String? = null, + multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("form-group")), StringFormControl { var options get() = input.options @@ -102,8 +104,10 @@ open class Select(options: List<StringPair>? = null, value: String? = null, } private val idc = "kv_form_select_" + counter - final override val input: SelectInput = SelectInput(options, value, multiple, ajaxOptions, - setOf("form-control")).apply { id = idc } + final override val input: SelectInput = SelectInput( + options, value, multiple, ajaxOptions, + setOf("form-control") + ).apply { id = idc } final override val flabel: FieldLabel = FieldLabel(idc, label, rich) final override val validationInfo: HelpBlock = HelpBlock().apply { visible = false } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt index 2dcbe99b..9e35fb6b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt @@ -1,9 +1,9 @@ package pl.treksoft.kvision.form.select import com.github.snabbdom.VNode +import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.CssSize import pl.treksoft.kvision.core.KVManager.KVNULL -import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.form.INPUTSIZE import pl.treksoft.kvision.html.BUTTONSTYLE import pl.treksoft.kvision.panel.SimplePanel @@ -17,9 +17,11 @@ enum class SELECTWIDTHTYPE(val value: String) { } @Suppress("TooManyFunctions") -open class SelectInput(options: List<StringPair>? = null, value: String? = null, - multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class SelectInput( + options: List<StringPair>? = null, value: String? = null, + multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, + classes: Set<String> = setOf() +) : SimplePanel(classes) { internal var options = options set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt index 38a578fe..cfd2be19 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOptGroup.kt @@ -4,8 +4,10 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.StringPair -open class SelectOptGroup(label: String, options: List<StringPair>? = null, maxOptions: Int? = null, - disabled: Boolean = false, classes: Set<String> = setOf()) : SimplePanel(classes) { +open class SelectOptGroup( + label: String, options: List<StringPair>? = null, maxOptions: Int? = null, + disabled: Boolean = false, classes: Set<String> = setOf() +) : SimplePanel(classes) { var label: String = label set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt index 3ff44c61..020d8f4b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectOption.kt @@ -4,9 +4,11 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.snabbdom.StringPair -open class SelectOption(value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null, - divider: Boolean = false, disabled: Boolean = false, - classes: Set<String> = setOf()) : Widget(classes) { +open class SelectOption( + value: String? = null, label: String? = null, subtext: String? = null, icon: String? = null, + divider: Boolean = false, disabled: Boolean = false, + classes: Set<String> = setOf() +) : Widget(classes) { var value: String? = value set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt index c6084fa8..5e2c460b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -8,10 +8,12 @@ import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.SnOn import pl.treksoft.kvision.snabbdom.StringBoolPair -open class Spinner(value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, label: String? = null, - rich: Boolean = false) : SimplePanel(setOf("form-group")), NumberFormControl { +open class Spinner( + value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, + decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, + forceType: FORCETYPE = FORCETYPE.NONE, label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("form-group")), NumberFormControl { override var value get() = input.value @@ -91,7 +93,7 @@ open class Spinner(value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, protected val idc = "kv_form_spinner_" + counter final override val input: SpinnerInput = SpinnerInput(value, min, max, step, decimals, buttonsType, forceType) - .apply { id = idc } + .apply { id = idc } final override val flabel: FieldLabel = FieldLabel(idc, label, rich) final override val validationInfo: HelpBlock = HelpBlock().apply { visible = false } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index b7d0f959..139a8ba9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -25,10 +25,12 @@ const val DEFAULT_STEP = 1.0 const val DEFAULT_MAX = 100 @Suppress("TooManyFunctions") -open class SpinnerInput(value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, - forceType: FORCETYPE = FORCETYPE.NONE, - classes: Set<String> = setOf()) : Widget(classes + "form-control") { +open class SpinnerInput( + value: Number? = null, min: Int = 0, max: Int = DEFAULT_MAX, step: Double = DEFAULT_STEP, + decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL, + forceType: FORCETYPE = FORCETYPE.NONE, + classes: Set<String> = setOf() +) : Widget(classes + "form-control") { init { this.addSurroundingCssClass("input-group") diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt index 8dd2a241..48b8d201 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt @@ -9,7 +9,7 @@ import pl.treksoft.kvision.snabbdom.SnOn import pl.treksoft.kvision.snabbdom.StringBoolPair abstract class AbstractText(label: String? = null, rich: Boolean = false) : - SimplePanel(setOf("form-group")), StringFormControl { + SimplePanel(setOf("form-group")), StringFormControl { override var value get() = input.value diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt index 88614774..85cf6cf7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt @@ -6,8 +6,10 @@ import pl.treksoft.kvision.form.INPUTSIZE import pl.treksoft.kvision.snabbdom.StringBoolPair import pl.treksoft.kvision.snabbdom.StringPair -abstract class AbstractTextInput(value: String? = null, - classes: Set<String> = setOf()) : Widget(classes) { +abstract class AbstractTextInput( + value: String? = null, + classes: Set<String> = setOf() +) : Widget(classes) { init { this.setInternalEventListener<AbstractTextInput> { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt index c5b8e622..cbdd7adf 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt @@ -1,4 +1,6 @@ package pl.treksoft.kvision.form.text -open class Password(value: String? = null, label: String? = null, rich: Boolean = false) : Text(TEXTINPUTTYPE.PASSWORD, - value, label, rich) +open class Password(value: String? = null, label: String? = null, rich: Boolean = false) : Text( + TEXTINPUTTYPE.PASSWORD, + value, label, rich +) diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt index 280c017d..6e1f8929 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt @@ -1,7 +1,9 @@ package pl.treksoft.kvision.form.text -open class RichText(value: String? = null, - label: String? = null, rich: Boolean = false) : AbstractText(label, rich) { +open class RichText( + value: String? = null, + label: String? = null, rich: Boolean = false +) : AbstractText(label, rich) { var inputHeight get() = input.height diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt index 5f791c94..c96bc371 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt @@ -6,7 +6,7 @@ import pl.treksoft.kvision.snabbdom.StringPair import kotlin.browser.document open class RichTextInput(value: String? = null, classes: Set<String> = setOf()) : - AbstractTextInput(value, classes + "form-control" + "trix-control") { + AbstractTextInput(value, classes + "form-control" + "trix-control") { private var trixId: String? = null diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt index db3233ba..a17c1b5d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt @@ -1,8 +1,10 @@ package pl.treksoft.kvision.form.text -open class Text(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, - label: String? = null, rich: Boolean = false) : AbstractText(label, rich) { +open class Text( + type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, + label: String? = null, rich: Boolean = false +) : AbstractText(label, rich) { var type get() = input.type diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt index 181298ac..e45d990d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt @@ -1,7 +1,9 @@ package pl.treksoft.kvision.form.text -open class TextArea(cols: Int? = null, rows: Int? = null, value: String? = null, - label: String? = null, rich: Boolean = false) : AbstractText(label, rich) { +open class TextArea( + cols: Int? = null, rows: Int? = null, value: String? = null, + label: String? = null, rich: Boolean = false +) : AbstractText(label, rich) { var cols get() = input.cols diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt index 2b5ff31d..01b531fb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt @@ -4,7 +4,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.snabbdom.StringPair open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf()) : - AbstractTextInput(value, classes + "form-control") { + AbstractTextInput(value, classes + "form-control") { var cols: Int? = cols set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt index 3cd86e04..d735c82e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt @@ -9,7 +9,7 @@ enum class TEXTINPUTTYPE(val type: String) { } open class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, classes: Set<String> = setOf()) : - AbstractTextInput(value, classes + "form-control") { + AbstractTextInput(value, classes + "form-control") { var type: TEXTINPUTTYPE = type set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt index 892467b7..db9fdeb1 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt @@ -9,8 +9,10 @@ import pl.treksoft.kvision.snabbdom.SnOn import pl.treksoft.kvision.snabbdom.StringBoolPair import kotlin.js.Date -open class DateTime(value: Date? = null, format: String = "YYYY-MM-DD HH:mm", label: String? = null, - rich: Boolean = false) : SimplePanel(setOf("form-group")), DateFormControl { +open class DateTime( + value: Date? = null, format: String = "YYYY-MM-DD HH:mm", label: String? = null, + rich: Boolean = false +) : SimplePanel(setOf("form-group")), DateFormControl { override var value get() = input.value diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt index 8db66834..a7aa758b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -14,8 +14,10 @@ const val DEFAULT_MINUTE_STEP = 5 const val MAX_VIEW = 4 @Suppress("TooManyFunctions") -open class DateTimeInput(value: Date? = null, format: String = "YYYY-MM-DD HH:mm", - classes: Set<String> = setOf()) : Widget(classes + "form-control") { +open class DateTimeInput( + value: Date? = null, format: String = "YYYY-MM-DD HH:mm", + classes: Set<String> = setOf() +) : Widget(classes + "form-control") { init { @@ -221,8 +223,8 @@ open class DateTimeInput(value: Date? = null, format: String = "YYYY-MM-DD HH:mm companion object { private fun String.toDatePickerFormat(): String { return this.replace("YY", "yy").replace("m", "i").replace("MMMM", "{----}").replace("MMM", "{---}") - .replace("M", "m").replace("{----}", "MM").replace("{---}", "M").replace("H", "{-}") - .replace("h", "H").replace("{-}", "h").replace("D", "d").replace("a", "p").replace("A", "P") + .replace("M", "m").replace("{----}", "MM").replace("{---}", "M").replace("H", "{-}") + .replace("h", "H").replace("{-}", "h").replace("D", "d").replace("a", "p").replace("A", "P") } } } |