diff options
Diffstat (limited to 'src')
92 files changed, 727 insertions, 302 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index d7b76862..51f0213b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -89,9 +89,11 @@ class Showcase : ApplicationBase() { val model = observableListOf(Model(true, "Pierwszy"), Model(false, "Drugi"), Model(false, "Trzeci")) val datac = DataContainer(model, { element, index -> - CheckBox(value = element.p, - label = if (element.p) "<b>" + (index + 1) + " " + element.t + "</b>" else element.t, - rich = true).setEventListener<CheckBox>({ + CheckBox( + value = element.p, + label = if (element.p) "<b>" + (index + 1) + " " + element.t + "</b>" else element.t, + rich = true + ).setEventListener<CheckBox>({ click = { element.p = self.value } @@ -409,12 +411,18 @@ class Showcase : ApplicationBase() { }*/ root.add(text) - val textareainput = TextAreaInput(cols = 5, rows = 2, value = "To jest tekst\nTo jest <b>te</b></textarea>kst2").apply { - placeholder = "..." - } + val textareainput = + TextAreaInput(cols = 5, rows = 2, value = "To jest tekst\nTo jest <b>te</b></textarea>kst2").apply { + placeholder = "..." + } root.add(textareainput) - val textarea = TextArea(cols = 5, rows = 2, value = "To jest tekst\nTo jest <b>te</b></textarea>kst2", label = "Pole długie").apply { + val textarea = TextArea( + cols = 5, + rows = 2, + value = "To jest tekst\nTo jest <b>te</b></textarea>kst2", + label = "Pole długie" + ).apply { placeholder = "..." } root.add(textarea) @@ -447,7 +455,7 @@ class Showcase : ApplicationBase() { it.getValue()?.matches("^[0-9]+$") } add("password", Password(label = "Hasło"), required = true, - validatorMessage = { "Wprowadź co najmniej 5 znaków" }) { + validatorMessage = { "Wprowadź co najmniej 5 znaków" }) { (it.getValue()?.length ?: 0) >= 5 } add("textarea", TextArea(label = "Obszar"), required = true) @@ -455,20 +463,26 @@ class Showcase : ApplicationBase() { add("data", DateTime(format = "YYYY-MM-DD", label = "Data"), required = true) add("checkbox", CheckBox(label = "Checkbox")) { it.getValue() } add("radio", Radio(label = "Radiobutton")) { it.getValue() } - add("select", Select(options = listOf("a" to "Pierwsza opcja", "b" to "Druga opcja"), - label = "Wybierz opcje").apply { + add("select", Select( + options = listOf("a" to "Pierwsza opcja", "b" to "Druga opcja"), + label = "Wybierz opcje" + ).apply { // selectWidthType = SELECTWIDTHTYPE.FIT emptyOption = true - }, required = true) + }, required = true + ) add("spinner", Spinner(label = "Spinner"), required = true) - add("radiogroup", RadioGroup(listOf("o1" to "Pierwsza opcja", "o2" to "Druga opcja"), - inline = true, label = "Radio group").apply { + add("radiogroup", RadioGroup( + listOf("o1" to "Pierwsza opcja", "o2" to "Druga opcja"), + inline = true, label = "Radio group" + ).apply { setEventListener<RadioGroup> { change = { e -> println(self.value) } } - }, required = true) + }, required = true + ) validator = { val result = it["text"] == it["textarea"] @@ -481,7 +495,14 @@ 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 { + 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 { @@ -527,9 +548,12 @@ class Showcase : ApplicationBase() { hiddenBsDropdown = { e -> println("hidden" + e.detail) } } - val dd2 = DropDown("Dropdown2", listOf("abc" to "#!/abc", "def" to "#!/def", "xyz" to DISABLED.type, + val dd2 = DropDown( + "Dropdown2", listOf( + "abc" to "#!/abc", "def" to "#!/def", "xyz" to DISABLED.type, "Header" to HEADER.type, "Separtatorek" to SEPARATOR.type - ), "flag").apply { dropup = true } + ), "flag" + ).apply { dropup = true } root.add(dd2) dd2.setEventListener<DropDown> { hideBsDropdown = { e -> println("hide" + e.detail) } @@ -564,14 +588,20 @@ class Showcase : ApplicationBase() { split.add(tabs) val split2 = SplitPanel(DIRECTION.HORIZONTAL) - val t1 = Tag(TAG.DIV, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus.\n" + - "\n" + - "Proin porttitor diam id massa eleifend aliquet. Morbi nec erat porttitor, placerat lorem et, dignissim lectus. Cras ultricies posuere arcu, et pharetra dui laoreet in. Sed nec ipsum in sapien vestibulum maximus eu id nunc. Ut finibus aliquam nisi id vehicula. Phasellus sodales lobortis orci, non interdum risus dignissim quis. Proin bibendum consectetur diam nec mattis. Suspendisse dictum vulputate metus at tincidunt.") + val t1 = Tag( + TAG.DIV, + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus.\n" + + "\n" + + "Proin porttitor diam id massa eleifend aliquet. Morbi nec erat porttitor, placerat lorem et, dignissim lectus. Cras ultricies posuere arcu, et pharetra dui laoreet in. Sed nec ipsum in sapien vestibulum maximus eu id nunc. Ut finibus aliquam nisi id vehicula. Phasellus sodales lobortis orci, non interdum risus dignissim quis. Proin bibendum consectetur diam nec mattis. Suspendisse dictum vulputate metus at tincidunt." + ) t1.padding = 5.px() split2.add(t1) - val t2 = Tag(TAG.DIV, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus.\n" + - "\n" + - "Proin porttitor diam id massa eleifend aliquet. Morbi nec erat porttitor, placerat lorem et, dignissim lectus. Cras ultricies posuere arcu, et pharetra dui laoreet in. Sed nec ipsum in sapien vestibulum maximus eu id nunc. Ut finibus aliquam nisi id vehicula. Phasellus sodales lobortis orci, non interdum risus dignissim quis. Proin bibendum consectetur diam nec mattis. Suspendisse dictum vulputate metus at tincidunt.") + val t2 = Tag( + TAG.DIV, + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus.\n" + + "\n" + + "Proin porttitor diam id massa eleifend aliquet. Morbi nec erat porttitor, placerat lorem et, dignissim lectus. Cras ultricies posuere arcu, et pharetra dui laoreet in. Sed nec ipsum in sapien vestibulum maximus eu id nunc. Ut finibus aliquam nisi id vehicula. Phasellus sodales lobortis orci, non interdum risus dignissim quis. Proin bibendum consectetur diam nec mattis. Suspendisse dictum vulputate metus at tincidunt." + ) t2.padding = 10.px() split2.add(t2) split.add(split2) @@ -596,8 +626,12 @@ class Showcase : ApplicationBase() { val del = Tag(TAG.DEL, "To jest deleted") root.add(del) - val list = ListTag(LIST.DL_HORIZ, listOf("abc", "de<b>fdasdasdasddasd</b>tdasdas", "Dasdsada", - "dasdasdads"), true) + val list = ListTag( + LIST.DL_HORIZ, listOf( + "abc", "de<b>fdasdasdasddasd</b>tdasdas", "Dasdsada", + "dasdasdads" + ), true + ) root.add(list) val list2 = ListTag(LIST.OL, null) @@ -642,8 +676,10 @@ class Showcase : ApplicationBase() { root.add(vPanel) val grid3 = GridPanel(templateColumns = "1fr 1fr 1fr") - grid3.background = Background(0xCCCCCC, Img("kotlin.png"), 50.perc(), 50.perc(), size = BGSIZE.CONTAIN, - repeat = BGREPEAT.NOREPEAT, attachment = BGATTACH.FIXED) + grid3.background = Background( + 0xCCCCCC, Img("kotlin.png"), 50.perc(), 50.perc(), size = BGSIZE.CONTAIN, + repeat = BGREPEAT.NOREPEAT, attachment = BGATTACH.FIXED + ) grid3.add(Label("hh1")) grid3.add(Label("hh2")) grid3.add(Label("hh3")) @@ -669,7 +705,10 @@ class Showcase : ApplicationBase() { // root.add(dock) val pa = HPanel(alignItems = FLEXALIGNITEMS.FLEXEND) - pa.add(Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus."), 3) + pa.add( + Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec fringilla turpis, vel molestie dolor. Vestibulum ut ex eget orci porta gravida eu sit amet tortor. Suspendisse vel fermentum purus, vel ornare tellus. Vivamus dictum, risus non viverra venenatis, magna mi pharetra purus, nec dignissim risus tortor a sem. Donec tincidunt dui ut eros laoreet consectetur. Nam dapibus vestibulum sem, eget accumsan ex vestibulum ac. Curabitur ac mi sit amet eros sodales dictum. Sed at felis at nunc aliquam finibus. Vestibulum lorem nulla, dictum ac libero non, mattis dictum nisl. Aenean semper lorem turpis. Praesent pellentesque ligula est, viverra molestie leo imperdiet ut. Nam vitae hendrerit justo. Nullam tincidunt et nibh ac volutpat. Aliquam vulputate mi aliquam fermentum rhoncus."), + 3 + ) pa.add(Image(Img("kotlin.png")), 1) pa.add(dock, 2, alignSelf = FLEXALIGNITEMS.FLEXSTART) dock.width = 400.px() @@ -751,9 +790,9 @@ class Showcase : ApplicationBase() { println("init routing") routing.on({ _ -> println("root") }) - .on("/abc", { _ -> println("abc") }) - .on("/test", { _ -> println("test") }) - .resolve() + .on("/abc", { _ -> println("abc") }) + .on("/test", { _ -> println("test") }) + .resolve() // jQuery(document).off(".data-api") // routing.on(RegExp("/abc/def/(.*)/(.*)/(.*)"), { x,y,z,u,v -> println(x) }) diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt index a645ac83..f533ebdd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt @@ -211,11 +211,15 @@ enum class BGCLIP(val clip: String) { CONTENT("content-box") } -class Border private constructor(private val width: CssSize? = null, private val style: BORDERSTYLE? = null, - private val color: String? = null) { +class Border private constructor( + private val width: CssSize? = null, private val style: BORDERSTYLE? = null, + private val color: String? = null +) { constructor(width: CssSize? = null, style: BORDERSTYLE? = null) : this(width, style, null) - constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: Int) : this(width, style, - "#" + color.toHexString()) + constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: Int) : this( + width, style, + "#" + color.toHexString() + ) constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: COLOR) : this(width, style, color.color) @@ -236,31 +240,45 @@ class Color private constructor(private val color: String? = null) { } } -class Background private constructor(private val color: String? = null, private val image: ResString? = null, - private val positionX: CssSize? = null, private val positionY: CssSize? = null, - private val sizeX: CssSize? = null, private val sizeY: CssSize? = null, - private val size: BGSIZE? = null, private val repeat: BGREPEAT? = null, - private val origin: BGORIGIN? = null, private val clip: BGCLIP? = null, - private val attachment: BGATTACH? = null) { - constructor(image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, - repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null) : this(null, - image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment) +class Background private constructor( + private val color: String? = null, private val image: ResString? = null, + private val positionX: CssSize? = null, private val positionY: CssSize? = null, + private val sizeX: CssSize? = null, private val sizeY: CssSize? = null, + private val size: BGSIZE? = null, private val repeat: BGREPEAT? = null, + private val origin: BGORIGIN? = null, private val clip: BGCLIP? = null, + private val attachment: BGATTACH? = null +) { + constructor( + image: ResString? = null, positionX: CssSize? = null, positionY: CssSize? = null, + sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, + repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, + attachment: BGATTACH? = null + ) : this( + null, + image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment + ) - constructor(color: Int, image: ResString? = null, positionX: CssSize? = null, - positionY: CssSize? = null, - sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, - repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null) : this("#" + - color.toHexString(), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, - attachment) + constructor( + color: Int, image: ResString? = null, positionX: CssSize? = null, + positionY: CssSize? = null, + sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null, + repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, + attachment: BGATTACH? = null + ) : this( + "#" + + color.toHexString(), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, + attachment + ) - constructor(color: COLOR, image: ResString? = null, positionX: CssSize? = null, - positionY: CssSize? = null, sizeX: CssSize? = null, sizeY: CssSize? = null, - size: BGSIZE? = null, repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, - attachment: BGATTACH? = null) : this(color.color, image, - positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment) + constructor( + color: COLOR, image: ResString? = null, positionX: CssSize? = null, + positionY: CssSize? = null, sizeX: CssSize? = null, sizeY: CssSize? = null, + size: BGSIZE? = null, repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null, + attachment: BGATTACH? = null + ) : this( + color.color, image, + positionX, positionY, sizeX, sizeY, size, repeat, origin, clip, attachment + ) fun asString(): String { val img = image?.let { diff --git a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt index 6739192d..4cd50550 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt @@ -26,7 +26,8 @@ object KVManager { private val bootstrapSelectI18n = require("./js/bootstrap-select-i18n.min.js") private val bootstrapSelectAjaxCss = require("ajax-bootstrap-select/dist/css/ajax-bootstrap-select.min.css") private val bootstrapSelectAjax = require("ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js") - private val bootstrapSelectAjaxI18n = require("ajax-bootstrap-select/dist/js/locale/ajax-bootstrap-select.pl-PL.min.js") + private val bootstrapSelectAjaxI18n = + require("ajax-bootstrap-select/dist/js/locale/ajax-bootstrap-select.pl-PL.min.js") private val trixCss = require("trix/dist/trix.css") private val trix = require("trix") private val bootstrapDateTimePickerCss = require("bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css") @@ -35,8 +36,12 @@ object KVManager { private val bootstrapTouchspin = require("bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js") internal val fecha = require("fecha") - private val sdPatch = Snabbdom.init(arrayOf(classModule, attributesModule, propsModule, styleModule, - eventListenersModule, datasetModule)) + private val sdPatch = Snabbdom.init( + arrayOf( + classModule, attributesModule, propsModule, styleModule, + eventListenersModule, datasetModule + ) + ) private val sdVirtualize = require("snabbdom-virtualize/strings").default private val styleCss = require("./css/style.css") diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index 8a7dfd15..28b0a076 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -349,8 +349,10 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent() { return this.parent?.getRoot() } - protected open fun createLabelWithIcon(label: String, icon: String? = null, - image: ResString? = null): Array<out Any> { + protected open fun createLabelWithIcon( + label: String, icon: String? = null, + image: ResString? = null + ): Array<out Any> { return if (icon != null) { if (icon.startsWith("fa-")) { arrayOf(KVManager.virtualize("<i class='fa $icon fa-lg'></i>"), " " + label) diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index 019ee414..4dbceaea 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -2,15 +2,17 @@ package pl.treksoft.kvision.data import com.github.snabbdom.VNode import com.lightningkite.kotlin.observable.list.ObservableList -import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Component +import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.panel.VPanel -class DataContainer<M : DataComponent, C : Widget>(val model: ObservableList<M>, - private val binding: (M, Int) -> C, - private val child: Container = VPanel()) : - Widget(setOf()), Container, DataUpdatable { +class DataContainer<M : DataComponent, C : Widget>( + val model: ObservableList<M>, + private val binding: (M, Int) -> C, + private val child: Container = VPanel() +) : + Widget(setOf()), Container, DataUpdatable { override var visible get() = child.visible diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index 880cb436..53d722b1 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -21,9 +21,11 @@ enum class DD(val type: String) { SEPARATOR("DD#SEPARATOR") } -open class DropDown(text: String, elements: List<StringPair>? = null, icon: String? = null, - style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class DropDown( + text: String, elements: List<StringPair>? = null, icon: String? = null, + style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false, + classes: Set<String> = setOf() +) : SimplePanel(classes) { var text get() = button.text set(value) { @@ -71,8 +73,10 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri } private val idc = "kv_dropdown_" + counter - internal val button: DropDownButton = DropDownButton(idc, text, icon, style, - disabled, setOf("dropdown")) + internal val button: DropDownButton = DropDownButton( + idc, text, icon, style, + disabled, setOf("dropdown") + ) internal val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu")) init { @@ -172,22 +176,28 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri } } -open class DropDownButton(id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, - disabled: Boolean = false, classes: Set<String> = setOf()) : - Button(text, icon, style, disabled, classes) { +open class DropDownButton( + id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + disabled: Boolean = false, classes: Set<String> = setOf() +) : + Button(text, icon, style, disabled, classes) { init { this.id = id } override fun getSnAttrs(): List<StringPair> { - return super.getSnAttrs() + listOf("data-toggle" to "dropdown", "aria-haspopup" to "true", - "aria-expanded" to "false") + return super.getSnAttrs() + listOf( + "data-toggle" to "dropdown", "aria-haspopup" to "true", + "aria-expanded" to "false" + ) } } -open class DropDownListTag(private val ariaId: String, classes: Set<String> = setOf()) : ListTag(LIST.UL, null, - false, classes) { +open class DropDownListTag(private val ariaId: String, classes: Set<String> = setOf()) : ListTag( + LIST.UL, null, + false, classes +) { override fun getSnAttrs(): List<StringPair> { return super.getSnAttrs() + listOf("aria-labelledby" to ariaId) 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") } } } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt index d14ce66e..ec0fd881 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt @@ -22,8 +22,10 @@ enum class BUTTONSIZE(val className: String) { XSMALL("btn-xs") } -open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, - disabled: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) { +open class Button( + text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + disabled: Boolean = false, classes: Set<String> = setOf() +) : Widget(classes) { var text = text set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt index 7097bdab..913735ef 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt @@ -12,8 +12,10 @@ enum class IMAGESHAPE(val className: String) { THUMBNAIL("img-thumbnail") } -open class Image(src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null, - centered: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) { +open class Image( + src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null, + centered: Boolean = false, classes: Set<String> = setOf() +) : Widget(classes) { internal var src = src set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt index f103323b..c61e8a79 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -1,12 +1,14 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode -import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.core.ResString +import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.StringPair -open class Link(label: String, url: String, icon: String? = null, image: ResString? = null, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class Link( + label: String, url: String, icon: String? = null, image: ResString? = null, + classes: Set<String> = setOf() +) : SimplePanel(classes) { private var label = label set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index 40ebc50b..eb006a33 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -2,8 +2,8 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode import com.github.snabbdom.h -import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.core.KVManager +import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.StringBoolPair enum class LIST(val tagName: String) { @@ -15,8 +15,10 @@ enum class LIST(val tagName: String) { DL_HORIZ("dl") } -open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = false, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class ListTag( + type: LIST, elements: List<String>? = null, rich: Boolean = false, + classes: Set<String> = setOf() +) : SimplePanel(classes) { var type = type set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index 71856627..ff22e440 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -1,8 +1,8 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode -import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.core.KVManager +import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.snabbdom.StringBoolPair @Suppress("EnumNaming") @@ -49,8 +49,10 @@ enum class ALIGN(val className: String) { NOWRAP("text-nowrap") } -open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class Tag( + type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, + classes: Set<String> = setOf() +) : SimplePanel(classes) { var type = type set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt index 39268ffa..5b8932cb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt @@ -7,9 +7,11 @@ import pl.treksoft.kvision.html.Button import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag -open class Alert(caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, - private val callback: (() -> Unit)? = null) : Modal(caption, true, size, animation) { +open class Alert( + caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + private val callback: (() -> Unit)? = null +) : Modal(caption, true, size, animation) { var text get() = content.text set(value) { @@ -47,9 +49,11 @@ open class Alert(caption: String? = null, text: String? = null, rich: Boolean = companion object { @Suppress("LongParameterList") - fun show(caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, - callback: (() -> Unit)? = null) { + fun show( + caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + callback: (() -> Unit)? = null + ) { Alert(caption, text, rich, align, size, animation, callback).show() } } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt index 90766854..05550f34 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt @@ -6,11 +6,13 @@ import pl.treksoft.kvision.html.Button import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag -open class Confirm(caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, - cancelVisible: Boolean = false, - private val noCallback: (() -> Unit)? = null, - private val yesCallback: (() -> Unit)? = null) : Modal(caption, false, size, animation, false) { +open class Confirm( + caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + cancelVisible: Boolean = false, + private val noCallback: (() -> Unit)? = null, + private val yesCallback: (() -> Unit)? = null +) : Modal(caption, false, size, animation, false) { var text get() = content.text set(value) { @@ -74,10 +76,12 @@ open class Confirm(caption: String? = null, text: String? = null, rich: Boolean companion object { @Suppress("LongParameterList") - fun show(caption: String? = null, text: String? = null, rich: Boolean = false, - align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, - cancelVisible: Boolean = false, - noCallback: (() -> Unit)? = null, yesCallback: (() -> Unit)? = null) { + fun show( + caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true, + cancelVisible: Boolean = false, + noCallback: (() -> Unit)? = null, yesCallback: (() -> Unit)? = null + ) { Confirm(caption, text, rich, align, size, animation, cancelVisible, noCallback, yesCallback).show() } } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index 08d56f4c..2c83077a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -19,9 +19,11 @@ enum class MODALSIZE(val className: String) { } @Suppress("TooManyFunctions") -open class Modal(caption: String? = null, closeButton: Boolean = true, - size: MODALSIZE? = null, animation: Boolean = true, private val escape: Boolean = true, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class Modal( + caption: String? = null, closeButton: Boolean = true, + size: MODALSIZE? = null, animation: Boolean = true, private val escape: Boolean = true, + classes: Set<String> = setOf() +) : SimplePanel(classes) { private var caption get() = captionTag.text set(value) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt index 376e34b9..e9670c1a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt @@ -17,8 +17,10 @@ open class DockPanel(classes: Set<String> = setOf()) : SimplePanel(classes = cla protected var up: Component? = null protected var down: Component? = null - protected val mainContainer = FlexPanel(direction = FLEXDIR.COLUMN, justify = FLEXJUSTIFY.SPACEBETWEEN, - alignItems = FLEXALIGNITEMS.STRETCH) + protected val mainContainer = FlexPanel( + direction = FLEXDIR.COLUMN, justify = FLEXJUSTIFY.SPACEBETWEEN, + alignItems = FLEXALIGNITEMS.STRETCH + ) protected val subContainer = FlexPanel(justify = FLEXJUSTIFY.SPACEBETWEEN, alignItems = FLEXALIGNITEMS.CENTER) init { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt index 80eddb23..86f1abc9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt @@ -43,9 +43,11 @@ enum class FLEXALIGNCONTENT(val alignContent: String) { STRETCH("stretch") } -open class FlexPanel(direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify: FLEXJUSTIFY? = null, - alignItems: FLEXALIGNITEMS? = null, alignContent: FLEXALIGNCONTENT? = null, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class FlexPanel( + direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify: FLEXJUSTIFY? = null, + alignItems: FLEXALIGNITEMS? = null, alignContent: FLEXALIGNCONTENT? = null, + classes: Set<String> = setOf() +) : SimplePanel(classes) { var direction = direction set(value) { field = value @@ -73,8 +75,10 @@ open class FlexPanel(direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify } @Suppress("LongParameterList") - fun add(child: Component, order: Int? = null, grow: Int? = null, shrink: Int? = null, - basis: Int? = null, alignSelf: FLEXALIGNITEMS? = null, classes: Set<String> = setOf()): FlexPanel { + fun add( + child: Component, order: Int? = null, grow: Int? = null, shrink: Int? = null, + basis: Int? = null, alignSelf: FLEXALIGNITEMS? = null, classes: Set<String> = setOf() + ): FlexPanel { addInternal(FlexWrapper(child, order, grow, shrink, basis, alignSelf, classes)) return this } @@ -128,10 +132,12 @@ open class FlexPanel(direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify } } -class FlexWrapper(delegate: Component, private val order: Int? = null, private val grow: Int? = null, - private val shrink: Int? = null, private val basis: Int? = null, - private val alignSelf: FLEXALIGNITEMS? = null, - classes: Set<String> = setOf()) : WidgetWrapper(delegate, classes) { +class FlexWrapper( + delegate: Component, private val order: Int? = null, private val grow: Int? = null, + private val shrink: Int? = null, private val basis: Int? = null, + private val alignSelf: FLEXALIGNITEMS? = null, + classes: Set<String> = setOf() +) : WidgetWrapper(delegate, classes) { override fun getSnStyle(): List<StringPair> { val snstyle = super.getSnStyle().toMutableList() diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt index dac5867c..3b226102 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt @@ -45,11 +45,13 @@ enum class GRIDFLOW(val flow: String) { COLUMNDENSE("column dense") } -open class GridPanel(autoColumns: String? = null, autoRows: String? = null, autoFlow: GRIDFLOW? = null, - templateColumns: String? = null, templateRows: String? = null, templateAreas: List<String>? = null, - columnGap: Int? = null, rowGap: Int? = null, justifyItems: GRIDJUSTIFY? = null, - alignItems: GRIDALIGN? = null, justifyContent: GRIDJUSTIFYCONTENT? = null, - alignContent: GRIDALIGNCONTENT? = null, classes: Set<String> = setOf()) : SimplePanel(classes) { +open class GridPanel( + autoColumns: String? = null, autoRows: String? = null, autoFlow: GRIDFLOW? = null, + templateColumns: String? = null, templateRows: String? = null, templateAreas: List<String>? = null, + columnGap: Int? = null, rowGap: Int? = null, justifyItems: GRIDJUSTIFY? = null, + alignItems: GRIDALIGN? = null, justifyContent: GRIDJUSTIFYCONTENT? = null, + alignContent: GRIDALIGNCONTENT? = null, classes: Set<String> = setOf() +) : SimplePanel(classes) { var autoColumns = autoColumns set(value) { field = value @@ -112,9 +114,11 @@ open class GridPanel(autoColumns: String? = null, autoRows: String? = null, auto } @Suppress("LongParameterList") - fun add(child: Component, columnStart: Int? = null, rowStart: Int? = null, - columnEnd: String? = null, rowEnd: String? = null, area: String? = null, justifySelf: GRIDJUSTIFY? = null, - alignSelf: GRIDALIGN? = null, classes: Set<String> = setOf()): GridPanel { + fun add( + child: Component, columnStart: Int? = null, rowStart: Int? = null, + columnEnd: String? = null, rowEnd: String? = null, area: String? = null, justifySelf: GRIDJUSTIFY? = null, + alignSelf: GRIDALIGN? = null, classes: Set<String> = setOf() + ): GridPanel { addInternal(GridWrapper(child, columnStart, rowStart, columnEnd, rowEnd, area, justifySelf, alignSelf, classes)) return this } @@ -190,11 +194,13 @@ open class GridPanel(autoColumns: String? = null, autoRows: String? = null, auto } } -class GridWrapper(delegate: Component, private val columnStart: Int? = null, private val rowStart: Int? = null, - private val columnEnd: String? = null, private val rowEnd: String? = null, - private val area: String? = null, private val justifySelf: GRIDJUSTIFY? = null, - private val alignSelf: GRIDALIGN? = null, - classes: Set<String> = setOf()) : WidgetWrapper(delegate, classes) { +class GridWrapper( + delegate: Component, private val columnStart: Int? = null, private val rowStart: Int? = null, + private val columnEnd: String? = null, private val rowEnd: String? = null, + private val area: String? = null, private val justifySelf: GRIDJUSTIFY? = null, + private val alignSelf: GRIDALIGN? = null, + classes: Set<String> = setOf() +) : WidgetWrapper(delegate, classes) { override fun getSnStyle(): List<StringPair> { val snstyle = super.getSnStyle().toMutableList() diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt index c9317374..93d60f1d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt @@ -1,5 +1,9 @@ package pl.treksoft.kvision.panel -open class HPanel(justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, - classes: Set<String> = setOf()) : FlexPanel(null, - null, justify, alignItems, null, classes) +open class HPanel( + justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, + classes: Set<String> = setOf() +) : FlexPanel( + null, + null, justify, alignItems, null, classes +) diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt index 88d70a64..740a208f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt @@ -17,9 +17,11 @@ const val MAX_COLUMNS = 12 internal data class WidgetParam(val widget: Component, val size: Int, val offset: Int) -open class ResponsiveGridPanel(private val gridsize: GRIDSIZE = GRIDSIZE.MD, - private var rows: Int = 0, private var cols: Int = 0, align: ALIGN? = null, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class ResponsiveGridPanel( + private val gridsize: GRIDSIZE = GRIDSIZE.MD, + private var rows: Int = 0, private var cols: Int = 0, align: ALIGN? = null, + classes: Set<String> = setOf() +) : SimplePanel(classes) { protected var align = align set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt index 90362127..51c42a06 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt @@ -1,8 +1,8 @@ package pl.treksoft.kvision.panel import com.github.snabbdom.VNode -import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Component +import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget open class SimplePanel(classes: Set<String> = setOf()) : Widget(classes), Container { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index b8c9c580..4f06a38f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -13,8 +13,10 @@ enum class DIRECTION(val dir: String) { VERTICAL("vertical") } -open class SplitPanel(private val direction: DIRECTION = DIRECTION.VERTICAL, - classes: Set<String> = setOf()) : SimplePanel(classes + ("splitpanel-" + direction.dir)) { +open class SplitPanel( + private val direction: DIRECTION = DIRECTION.VERTICAL, + classes: Set<String> = setOf() +) : SimplePanel(classes + ("splitpanel-" + direction.dir)) { @Suppress("LeakingThis") internal val splitter = Splitter(this, direction) @@ -56,8 +58,10 @@ open class SplitPanel(private val direction: DIRECTION = DIRECTION.VERTICAL, } } -class Splitter(private val splitPanel: SplitPanel, direction: DIRECTION) : Tag(TAG.DIV, - classes = setOf("splitter-" + direction.dir)) { +class Splitter(private val splitPanel: SplitPanel, direction: DIRECTION) : Tag( + TAG.DIV, + classes = setOf("splitter-" + direction.dir) +) { private val idc = "kv_splitter_" + counter init { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt index 55bd2cca..1d4b1b68 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt @@ -3,8 +3,10 @@ package pl.treksoft.kvision.panel import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Component -open class StackPanel(private val activateLast: Boolean = true, - classes: Set<String> = setOf()) : SimplePanel(classes) { +open class StackPanel( + private val activateLast: Boolean = true, + classes: Set<String> = setOf() +) : SimplePanel(classes) { var activeIndex = -1 set(value) { field = value diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt index e60d9480..72063be0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt @@ -25,8 +25,10 @@ open class TabPanel : SimplePanel(setOf()) { this.addInternal(content) } - open fun addTab(title: String, panel: Component, icon: String? = null, - image: ResString? = null): TabPanel { + open fun addTab( + title: String, panel: Component, icon: String? = null, + image: ResString? = null + ): TabPanel { val tag = Tag(TAG.LI) tag.role = "presentation" tag.add(Link(title, "#", icon, image)) diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt index 42e33637..883d9d75 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt @@ -1,5 +1,9 @@ package pl.treksoft.kvision.panel -open class VPanel(justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, - classes: Set<String> = setOf()) : FlexPanel(FLEXDIR.COLUMN, - null, justify, alignItems, null, classes) +open class VPanel( + justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, + classes: Set<String> = setOf() +) : FlexPanel( + FLEXDIR.COLUMN, + null, justify, alignItems, null, classes +) diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt index a169ace6..e0bc16da 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt @@ -1,8 +1,8 @@ package test.pl.treksoft.kvision.core -import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.core.Root import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.panel.SimplePanel import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document import kotlin.test.Test @@ -82,6 +82,7 @@ class ContainerSpec : DomSpec { assertTrue("Children are not rendered") { elem1 == null && elem2 == null } } } + @Test fun getChildren() { run { diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt index a053627d..01aee755 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt @@ -20,7 +20,11 @@ class WidgetWrapperSpec : DomSpec { wrapper.width = 100 to UNIT.em root.add(wrapper) val element = document.getElementById("test") - assertEquals("<div style=\"width: 100em;\"><div></div></div>", element?.innerHTML, "Should render widget inside custom wrapper") + assertEquals( + "<div style=\"width: 100em;\"><div></div></div>", + element?.innerHTML, + "Should render widget inside custom wrapper" + ) widget.hide() assertEquals("", element?.innerHTML, "Should not render wrapper when widget is hidden") } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt index 7b9b16e4..30cf0db9 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt @@ -16,18 +16,32 @@ class DataContainerSpec : DomSpec { fun render() { run { val root = Root("test") + class Model(value: String) : DataComponent() { var value: String by obs(value) } + val model = observableListOf(Model("First"), Model("Second")) val container = DataContainer(model, { element, _ -> Label(element.value) }) root.add(container) val element = document.getElementById("test") - assertEquals("<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div></div>", element?.innerHTML, "Should render correct data container") + assertEquals( + "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div></div>", + element?.innerHTML, + "Should render correct data container" + ) model.add(Model("Third")) - assertEquals("<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div><div><span>Third</span></div></div>", element?.innerHTML, "Should render correct data container after model change") + assertEquals( + "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div><div><span>Third</span></div></div>", + element?.innerHTML, + "Should render correct data container after model change" + ) model[1].value = "Changed" - assertEquals("<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Changed</span></div><div><span>Third</span></div></div>", element?.innerHTML, "Should render correct data container after model element change") + assertEquals( + "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Changed</span></div><div><span>Third</span></div></div>", + element?.innerHTML, + "Should render correct data container after model element change" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt index 6cfd948a..cd4f8930 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt @@ -20,7 +20,11 @@ class DropDownSpec : DomSpec { dd.toggle() val element = document.getElementById("test") val id = dd.button.id - assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down") + assertEquals( + "<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", + element?.innerHTML, + "Should render correct drop down" + ) } } @@ -33,7 +37,11 @@ class DropDownSpec : DomSpec { dd.toggle() val element = document.getElementById("test") val id = dd.button.id - assertEquals("<div class=\"dropup\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down") + assertEquals( + "<div class=\"dropup\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", + element?.innerHTML, + "Should render correct drop down" + ) } } @@ -46,7 +54,11 @@ class DropDownSpec : DomSpec { dd.toggle() val element = document.getElementById("test") val id = dd.button.id - assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"dropdown-header\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down") + assertEquals( + "<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"dropdown-header\">abc</li></ul></div>", + element?.innerHTML, + "Should render correct drop down" + ) } } @@ -59,7 +71,11 @@ class DropDownSpec : DomSpec { dd.toggle() val element = document.getElementById("test") val id = dd.button.id - assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down") + assertEquals( + "<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", + element?.innerHTML, + "Should render correct drop down" + ) } } @@ -72,7 +88,11 @@ class DropDownSpec : DomSpec { dd.toggle() val element = document.getElementById("test") val id = dd.button.id - assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", element?.innerHTML, "Should render correct drop down") + assertEquals( + "<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", + element?.innerHTML, + "Should render correct drop down" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt index 9aa9328e..fa206efd 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt @@ -16,7 +16,11 @@ class FieldLabelSpec : DomSpec { val fl = FieldLabel("input", "Label") root.add(fl) val element = document.getElementById("test") - assertEquals("<label class=\"control-label\" for=\"input\">Label</label>", element?.innerHTML, "Should render correct label") + assertEquals( + "<label class=\"control-label\" for=\"input\">Label</label>", + element?.innerHTML, + "Should render correct label" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt index d325dc0f..1b8d2a6a 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt @@ -16,7 +16,11 @@ class HelpBlockSpec : DomSpec { val fl = HelpBlock("Form Error") root.add(fl) val element = document.getElementById("test") - assertEquals("<span class=\"help-block small\">Form Error</span>", element?.innerHTML, "Should render correct help block") + assertEquals( + "<span class=\"help-block small\">Form Error</span>", + element?.innerHTML, + "Should render correct help block" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt index f0cdc795..e049aa17 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt @@ -24,11 +24,19 @@ class CheckBoxSpec : DomSpec { root.add(ci) val element = document.getElementById("test") val id = ci.input.id - assertEquals("<div class=\"checkbox checkbox-danger checkbox-circle checkbox-inline\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct checkbox form control") + assertEquals( + "<div class=\"checkbox checkbox-danger checkbox-circle checkbox-inline\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", + element?.innerHTML, + "Should render correct checkbox form control" + ) ci.style = CHECKBOXSTYLE.INFO ci.circled = false ci.inline = false - assertEquals("<div class=\"checkbox checkbox-info\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct checkbox form control") + assertEquals( + "<div class=\"checkbox checkbox-info\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", + element?.innerHTML, + "Should render correct checkbox form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt index 61b14a93..584b1232 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt @@ -21,7 +21,11 @@ class CheckInputSpec : DomSpec { } root.add(ci) val element = document.getElementById("test") - assertEquals("<input id=\"idti\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\">", element?.innerHTML, "Should render correct checkbox control") + assertEquals( + "<input id=\"idti\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\">", + element?.innerHTML, + "Should render correct checkbox control" + ) } } @@ -36,7 +40,11 @@ class CheckInputSpec : DomSpec { } root.add(ci) val element = document.getElementById("test") - assertEquals("<input id=\"idti\" type=\"radio\" checked=\"\" name=\"name\" value=\"abc\">", element?.innerHTML, "Should render correct radio button control") + assertEquals( + "<input id=\"idti\" type=\"radio\" checked=\"\" name=\"name\" value=\"abc\">", + element?.innerHTML, + "Should render correct radio button control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt index b1dc19ea..d301a533 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt @@ -23,7 +23,11 @@ class RadioGroupSpec : DomSpec { val id = ci.flabel.forId val rid1 = ci.getChildren().filterIsInstance<Radio>().first().input.id val rid2 = ci.getChildren().filterIsInstance<Radio>().last().input.id - assertEquals("<div class=\"form-group kv-radiogroup-inline\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"radio\"><input id=\"$rid1\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"a\"><label for=\"$rid1\">A</label></div><div class=\"radio\"><input id=\"$rid2\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"b\"><label for=\"$rid2\">B</label></div></div>", element?.innerHTML, "Should render correct radio button group form control") + assertEquals( + "<div class=\"form-group kv-radiogroup-inline\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"radio\"><input id=\"$rid1\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"a\"><label for=\"$rid1\">A</label></div><div class=\"radio\"><input id=\"$rid2\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"b\"><label for=\"$rid2\">B</label></div></div>", + element?.innerHTML, + "Should render correct radio button group form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt index a2a87b0f..d32a84a3 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt @@ -23,11 +23,19 @@ class RadioSpec : DomSpec { root.add(ci) val element = document.getElementById("test") val id = ci.input.id - assertEquals("<div class=\"radio radio-danger radio-inline\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct radio button form control") + assertEquals( + "<div class=\"radio radio-danger radio-inline\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", + element?.innerHTML, + "Should render correct radio button form control" + ) ci.style = RADIOSTYLE.INFO ci.squared = true ci.inline = false - assertEquals("<div class=\"checkbox checkbox-info\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct radio button form control") + assertEquals( + "<div class=\"checkbox checkbox-info\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", + element?.innerHTML, + "Should render correct radio button form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt index 4f3544b9..28f9eb03 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt @@ -22,7 +22,10 @@ class SelectInputSpec : DomSpec { } root.add(selectInput) val element = document.getElementById("test") - assertTrue(true == element?.innerHTML?.endsWith("<select class=\"selectpicker\" multiple=\"\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div>"), "Should render correct select input") + assertTrue( + true == element?.innerHTML?.endsWith("<select class=\"selectpicker\" multiple=\"\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div>"), + "Should render correct select input" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt index 90348f15..8562d3cc 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt @@ -17,9 +17,17 @@ class SelectOptGroupSpec : DomSpec { val selectOptGroup = SelectOptGroup("Group", listOf("test1" to "Test 1", "test2" to "Test 2"), 2) root.add(selectOptGroup) val element = document.getElementById("test") - assertEquals("<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></optgroup>", element?.innerHTML, "Should render correct select option group") + assertEquals( + "<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></optgroup>", + element?.innerHTML, + "Should render correct select option group" + ) selectOptGroup.add(SelectOption("test3", "Test 3")) - assertEquals("<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option><option value=\"test3\">Test 3</option></optgroup>", element?.innerHTML, "Should render correct select option group with added option") + assertEquals( + "<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option><option value=\"test3\">Test 3</option></optgroup>", + element?.innerHTML, + "Should render correct select option group with added option" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt index 007db186..221d46b0 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt @@ -16,11 +16,23 @@ class SelectOptionSpec : DomSpec { val selectOption = SelectOption("testValue", "testLabel") root.add(selectOption) val element = document.getElementById("test") - assertEquals("<option value=\"testValue\">testLabel</option>", element?.innerHTML, "Should render correct select option") + assertEquals( + "<option value=\"testValue\">testLabel</option>", + element?.innerHTML, + "Should render correct select option" + ) selectOption.icon = "fa-flag" - assertEquals("<option value=\"testValue\" data-icon=\"fa fa-flag\">testLabel</option>", element?.innerHTML, "Should render correct select option with icon") + assertEquals( + "<option value=\"testValue\" data-icon=\"fa fa-flag\">testLabel</option>", + element?.innerHTML, + "Should render correct select option with icon" + ) selectOption.divider = true - assertEquals("<option data-divider=\"true\"></option>", element?.innerHTML, "Should render correct divider option") + assertEquals( + "<option data-divider=\"true\"></option>", + element?.innerHTML, + "Should render correct divider option" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt index 1c44e820..1afb6c79 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt @@ -23,8 +23,14 @@ class SelectSpec : DomSpec { root.add(select) val element = document.getElementById("test") val id = select.input.id - assertTrue(true == element?.innerHTML?.startsWith("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label>"), "Should render correct select form control") - assertTrue(true == element?.innerHTML?.endsWith("<select class=\"form-control selectpicker\" id=\"$id\" multiple=\"\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div></div>"), "Should render correct select form control") + assertTrue( + true == element?.innerHTML?.startsWith("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label>"), + "Should render correct select form control" + ) + assertTrue( + true == element?.innerHTML?.endsWith("<select class=\"form-control selectpicker\" id=\"$id\" multiple=\"\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div></div>"), + "Should render correct select form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt index b800f297..8a7a346b 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt @@ -21,9 +21,17 @@ class SpinnerSpec : DomSpec { root.add(ti) val element = document.getElementById("test") val id = ti.input.id - assertEquals("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div></div>", element?.innerHTML, "Should render correct spinner input form control") + assertEquals( + "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div></div>", + element?.innerHTML, + "Should render correct spinner input form control" + ) ti.validatorError = "Validation Error" - assertEquals("<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div><span class=\"help-block small\">Validation Error</span></div>", element?.innerHTML, "Should render correct spinner input form control with validation error") + assertEquals( + "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div><span class=\"help-block small\">Validation Error</span></div>", + element?.innerHTML, + "Should render correct spinner input form control with validation error" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt index cdbbdd4e..1cbb29cc 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt @@ -22,7 +22,11 @@ class PasswordSpec : DomSpec { root.add(ti) val element = document.getElementById("test") val id = ti.input.id - assertEquals("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"password\" value=\"abc\"></div>", element?.innerHTML, "Should render correct input form control") + assertEquals( + "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"password\" value=\"abc\"></div>", + element?.innerHTML, + "Should render correct input form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt index 6910c4a2..92e0e9ff 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt @@ -21,7 +21,11 @@ class RichTextInputSpec : DomSpec { root.add(hai) val id = document.getElementById("test")?.let { jQuery(it).find("trix-editor").attr("trix-id") } ?: "0" val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML } - assertEquals("<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"idti\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", content, "Should render correct html area control") + assertEquals( + "<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"idti\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", + content, + "Should render correct html area control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt index ef7374df..28ce2ee7 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt @@ -22,9 +22,17 @@ class RichTextSpec : DomSpec { val id = document.getElementById("test")?.let { jQuery(it).find("trix-editor").attr("trix-id") } ?: "0" val iid = hai.input.id val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML } - assertEquals("<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"$iid\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", content, "Should render correct html area form control") + assertEquals( + "<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"$iid\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", + content, + "Should render correct html area form control" + ) val label = document.getElementById("test")?.let { jQuery(it).find("label")[0]?.outerHTML } - assertEquals("<label class=\"control-label\" for=\"$iid\">Field</label>", label, "Should render correct label for html area form control") + assertEquals( + "<label class=\"control-label\" for=\"$iid\">Field</label>", + label, + "Should render correct label for html area form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt index f60e21cb..a27e959d 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt @@ -22,7 +22,11 @@ class TextAreaInputSpec : DomSpec { } root.add(ti) val element = document.getElementById("test") - assertEquals("<textarea class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" cols=\"5\" rows=\"2\">abc</textarea>", element?.innerHTML, "Should render correct input control") + assertEquals( + "<textarea class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" cols=\"5\" rows=\"2\">abc</textarea>", + element?.innerHTML, + "Should render correct input control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt index 1a3ff550..8f9cf639 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt @@ -22,7 +22,11 @@ class TextAreaSpec : DomSpec { root.add(ti) val element = document.getElementById("test") val id = ti.input.id - assertEquals("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><textarea class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" cols=\"5\" rows=\"2\">abc</textarea></div>", element?.innerHTML, "Should render correct input form control") + assertEquals( + "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><textarea class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" cols=\"5\" rows=\"2\">abc</textarea></div>", + element?.innerHTML, + "Should render correct input form control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt index a82a5681..a3402c45 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt @@ -23,7 +23,11 @@ class TextInputSpec : DomSpec { } root.add(ti) val element = document.getElementById("test") - assertEquals("<input class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"password\" value=\"abc\">", element?.innerHTML, "Should render correct input control") + assertEquals( + "<input class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"password\" value=\"abc\">", + element?.innerHTML, + "Should render correct input control" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt index 1e9a5b6c..77741f26 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt @@ -22,9 +22,17 @@ class TextSpec : DomSpec { root.add(ti) val element = document.getElementById("test") val id = ti.input.id - assertEquals("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"text\" value=\"abc\"></div>", element?.innerHTML, "Should render correct input form control") + assertEquals( + "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"text\" value=\"abc\"></div>", + element?.innerHTML, + "Should render correct input form control" + ) ti.validatorError = "Validation Error" - assertEquals("<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"text\" value=\"abc\"><span class=\"help-block small\">Validation Error</span></div>", element?.innerHTML, "Should render correct input form control with validation error") + assertEquals( + "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"text\" value=\"abc\"><span class=\"help-block small\">Validation Error</span></div>", + element?.innerHTML, + "Should render correct input form control with validation error" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt index fe6c2b45..909c4928 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt @@ -21,7 +21,11 @@ class DateTimeInputSpec : DomSpec { } root.add(dti) val value = dti.getElementJQuery()?.`val`() - assertEquals(data.toStringF(dti.format), value, "Should render date time input with correctly formatted value") + assertEquals( + data.toStringF(dti.format), + value, + "Should render date time input with correctly formatted value" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt index 1a8665b1..8ac43174 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt @@ -25,9 +25,17 @@ class DateTimeSpec : DomSpec { val element = document.getElementById("test") val id = ti.input.id val datastr = data.toStringF(ti.format) - assertEquals("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"\" value=\"$datastr\"></div>", element?.innerHTML, "Should render correct date time input form control") + assertEquals( + "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"\" value=\"$datastr\"></div>", + element?.innerHTML, + "Should render correct date time input form control" + ) ti.validatorError = "Validation Error" - assertEquals("<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"\" value=\"$datastr\"><span class=\"help-block small\">Validation Error</span></div>", element?.innerHTML, "Should render correct date time input form control with validation error") + assertEquals( + "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"\" value=\"$datastr\"><span class=\"help-block small\">Validation Error</span></div>", + element?.innerHTML, + "Should render correct date time input form control with validation error" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/helpers/CloseIconSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/helpers/CloseIconSpec.kt index a36beafa..eb573d4f 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/helpers/CloseIconSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/helpers/CloseIconSpec.kt @@ -16,7 +16,11 @@ class CloseIconSpec : DomSpec { val ci = CloseIcon() root.add(ci) val element = document.getElementById("test") - assertEquals("<button class=\"close\" type=\"button\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>", element?.innerHTML, "Should render correct close icon") + assertEquals( + "<button class=\"close\" type=\"button\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>", + element?.innerHTML, + "Should render correct close icon" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt index 681b3db3..77061f62 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt @@ -20,7 +20,11 @@ class ButtonSpec : DomSpec { button.block = true root.add(button) val element = document.getElementById("test") - assertEquals("<button class=\"btn btn-primary btn-lg btn-block\" type=\"button\"><i class=\"fa fa-bars fa-lg\"></i> Cancel</button>", element?.innerHTML, "Should render correct html button") + assertEquals( + "<button class=\"btn btn-primary btn-lg btn-block\" type=\"button\"><i class=\"fa fa-bars fa-lg\"></i> Cancel</button>", + element?.innerHTML, + "Should render correct html button" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt index ebf3aedb..8afa7317 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt @@ -19,7 +19,11 @@ class ImageSpec : DomSpec { val image = Image(res, "Image", true, IMAGESHAPE.ROUNDED, true) root.add(image) val element = document.getElementById("test") - assertEquals("<img class=\"img-responsive center-block img-rounded\" src=\"$res\" alt=\"Image\">", element?.innerHTML, "Should render correct html image") + assertEquals( + "<img class=\"img-responsive center-block img-rounded\" src=\"$res\" alt=\"Image\">", + element?.innerHTML, + "Should render correct html image" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt index 1f4b6d2c..0087f56a 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt @@ -16,7 +16,11 @@ class LinkSpec : DomSpec { val link = Link("Google", "http://www.google.com") root.add(link) val element = document.getElementById("test") - assertEquals("<a href=\"http://www.google.com\">Google</a>", element?.innerHTML, "Should render correct html link") + assertEquals( + "<a href=\"http://www.google.com\">Google</a>", + element?.innerHTML, + "Should render correct html link" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt index 48a13f6d..bdf1ca0f 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt @@ -19,7 +19,11 @@ class ListSpec : DomSpec { val list = ListTag(LIST.DL_HORIZ, listOf("a1", "a2", "b1", "b2")) root.add(list) val element = document.getElementById("test") - assertEquals("<dl class=\"dl-horizontal\"><dt>a1</dt><dd>a2</dd><dt>b1</dt><dd>b2</dd></dl>", element?.innerHTML, "Should render correct html list") + assertEquals( + "<dl class=\"dl-horizontal\"><dt>a1</dt><dd>a2</dd><dt>b1</dt><dd>b2</dd></dl>", + element?.innerHTML, + "Should render correct html list" + ) } } @@ -32,7 +36,11 @@ class ListSpec : DomSpec { list.add(Tag(TAG.DEL, "del")) root.add(list) val element = document.getElementById("test") - assertEquals("<ul><li><pre>pre</pre></li><li><del>del</del></li></ul>", element?.innerHTML, "Should render correct html list") + assertEquals( + "<ul><li><pre>pre</pre></li><li><del>del</del></li></ul>", + element?.innerHTML, + "Should render correct html list" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt index 8d6a19d1..9840ff3e 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt @@ -19,7 +19,11 @@ class TagSpec : DomSpec { val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = false, align = ALIGN.CENTER) root.add(tag) val element = document.getElementById("test") - assertEquals("<h1 class=\"text-center\">This is <b>h1</b></h1>", element?.innerHTML, "Should render correct html tag") + assertEquals( + "<h1 class=\"text-center\">This is <b>h1</b></h1>", + element?.innerHTML, + "Should render correct html tag" + ) } } @@ -30,7 +34,11 @@ class TagSpec : DomSpec { val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = true, align = ALIGN.RIGHT) root.add(tag) val element = document.getElementById("test") - assertEquals("<h1 class=\"text-right\"><span>This is <b>h1</b></span></h1>", element?.innerHTML, "Should render correct html tag") + assertEquals( + "<h1 class=\"text-right\"><span>This is <b>h1</b></span></h1>", + element?.innerHTML, + "Should render correct html tag" + ) } } @@ -43,7 +51,11 @@ class TagSpec : DomSpec { tag.add(Link("abc", "/x")) root.add(tag) val element = document.getElementById("test") - assertEquals("<p class=\"text-right\"><del>This is test</del><a href=\"/x\">abc</a></p>", element?.innerHTML, "Should render correct html tag with children") + assertEquals( + "<p class=\"text-right\"><del>This is test</del><a href=\"/x\">abc</a></p>", + element?.innerHTML, + "Should render correct html tag with children" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt index 328bbfca..15ca9b50 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt @@ -24,7 +24,11 @@ class AlertSpec : DomSpec { val body = document.getElementById("test")?.let { jQuery(it).find(".modal-body").html() } assertEquals("<span>Alert content</span>", body, "Should render alert window with correct content") val footer = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").html() } - assertEquals("<button class=\"btn btn-primary\" type=\"button\"><span class=\"glyphicon glyphicon-ok\"></span> OK</button>", footer, "Should render alert window with correct footer") + assertEquals( + "<button class=\"btn btn-primary\" type=\"button\"><span class=\"glyphicon glyphicon-ok\"></span> OK</button>", + footer, + "Should render alert window with correct footer" + ) val button = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").find("button") } button?.click() val alert2 = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt index 9e91be0a..0d3bbc72 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt @@ -2,7 +2,6 @@ package test.pl.treksoft.kvision.modal import pl.treksoft.jquery.jQuery import pl.treksoft.kvision.core.Root -import pl.treksoft.kvision.modal.Alert import pl.treksoft.kvision.modal.Confirm import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt index 73754d60..a83bbc6a 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt @@ -23,7 +23,11 @@ class DockPanelSpec : DomSpec { dockPanel.add(Label("jkl"), SIDE.LEFT) dockPanel.add(Label("mno"), SIDE.CENTER) val element = document.getElementById("test") - assertEquals("<div><div style=\"display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;\"><div style=\"order: 2;\"><div style=\"display: flex; justify-content: space-between; align-items: center;\"><div style=\"order: 3;\"><span>def</span></div><div style=\"order: 1;\"><span>jkl</span></div><div style=\"order: 2;\"><span>mno</span></div></div></div><div style=\"order: 1; align-self: center;\"><span>abc</span></div><div style=\"order: 3; align-self: center;\"><span>ghi</span></div></div></div>", element?.innerHTML, "Should render correct dock panel") + assertEquals( + "<div><div style=\"display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;\"><div style=\"order: 2;\"><div style=\"display: flex; justify-content: space-between; align-items: center;\"><div style=\"order: 3;\"><span>def</span></div><div style=\"order: 1;\"><span>jkl</span></div><div style=\"order: 2;\"><span>mno</span></div></div></div><div style=\"order: 1; align-self: center;\"><span>abc</span></div><div style=\"order: 3; align-self: center;\"><span>ghi</span></div></div></div>", + element?.innerHTML, + "Should render correct dock panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt index 3f5885fa..e1c3d160 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt @@ -22,7 +22,11 @@ class FlexPanelSpec : DomSpec { flexPanel.add(Label("def"), 2) flexPanel.add(Label("ghi"), 3) val element = document.getElementById("test") - assertEquals("<div style=\"display: flex; flex-direction: row-reverse; justify-content: space-evenly;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", element?.innerHTML, "Should render correct flex panel") + assertEquals( + "<div style=\"display: flex; flex-direction: row-reverse; justify-content: space-evenly;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", + element?.innerHTML, + "Should render correct flex panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt index 547baafe..571f13e9 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt @@ -20,7 +20,11 @@ class GridPanelSpec : DomSpec { gridPanel.add(Label("def"), 2, 2) gridPanel.add(Label("ghi"), 3, 3) val element = document.getElementById("test") - assertEquals("<div style=\"display: grid;\"><div style=\"grid-column-start: 1; grid-row-start: 1;\"><span>abc</span></div><div style=\"grid-column-start: 2; grid-row-start: 2;\"><span>def</span></div><div style=\"grid-column-start: 3; grid-row-start: 3;\"><span>ghi</span></div></div>", element?.innerHTML, "Should render correct grid panel") + assertEquals( + "<div style=\"display: grid;\"><div style=\"grid-column-start: 1; grid-row-start: 1;\"><span>abc</span></div><div style=\"grid-column-start: 2; grid-row-start: 2;\"><span>def</span></div><div style=\"grid-column-start: 3; grid-row-start: 3;\"><span>ghi</span></div></div>", + element?.innerHTML, + "Should render correct grid panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt index 48449fc2..589bd9df 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt @@ -21,7 +21,11 @@ class HPanelSpec : DomSpec { hPanel.add(Label("def"), 2) hPanel.add(Label("ghi"), 3) val element = document.getElementById("test") - assertEquals("<div style=\"display: flex; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", element?.innerHTML, "Should render correct horizontal panel") + assertEquals( + "<div style=\"display: flex; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", + element?.innerHTML, + "Should render correct horizontal panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt index 5fb9376d..2bbb3774 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt @@ -20,7 +20,11 @@ class ResponsiveGridPanelSpec : DomSpec { rgPanel.add(Label("def"), 2, 2) rgPanel.add(Label("ghi"), 3, 3) val element = document.getElementById("test") - assertEquals("<div><div class=\"row\"></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>abc</span></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>def</span></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>ghi</span></div></div></div>", element?.innerHTML, "Should render correct responsive grid panel") + assertEquals( + "<div><div class=\"row\"></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>abc</span></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>def</span></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>ghi</span></div></div></div>", + element?.innerHTML, + "Should render correct responsive grid panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt index e3442f59..0cce9bb5 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt @@ -1,17 +1,13 @@ package test.pl.treksoft.kvision.panel -import pl.treksoft.jquery.jQuery import pl.treksoft.kvision.basic.Label import pl.treksoft.kvision.core.Root -import pl.treksoft.kvision.modal.Alert import pl.treksoft.kvision.panel.DIRECTION import pl.treksoft.kvision.panel.SplitPanel import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull class SplitPanelSpec : DomSpec { @@ -27,7 +23,11 @@ class SplitPanelSpec : DomSpec { splitPanel.add(label2) val element = document.getElementById("test") val id = splitPanel.splitter.id - assertEquals("<div class=\"splitpanel-vertical\"><span class=\"resizable\">abc</span><div class=\"splitter-vertical\" id=\"$id\" style=\"touch-action: none;\"></div><span>def</span></div>", element?.innerHTML, "Should render correct split panel") + assertEquals( + "<div class=\"splitpanel-vertical\"><span class=\"resizable\">abc</span><div class=\"splitter-vertical\" id=\"$id\" style=\"touch-action: none;\"></div><span>def</span></div>", + element?.innerHTML, + "Should render correct split panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt index 9484c194..f9f3f68a 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt @@ -36,7 +36,11 @@ class StackPanelSpec : DomSpec { stackPanel.add(label1) stackPanel.add(label2) val element = document.getElementById("test") - assertEquals("<div><span>abc</span></div>", element?.innerHTML, "Should render correct stack panel with activateLast = false") + assertEquals( + "<div><span>abc</span></div>", + element?.innerHTML, + "Should render correct stack panel with activateLast = false" + ) } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt index 4a1f9652..eea5710e 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt @@ -21,7 +21,11 @@ class TabPanelSpec : DomSpec { tabs.addTab("ABC", label1) tabs.addTab("DEF", label2) val element = document.getElementById("test") - assertEquals("<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"active\"><a href=\"#\">ABC</a></li><li role=\"presentation\"><a href=\"#\">DEF</a></li></ul><div><span>abc</span></div></div>", element?.innerHTML, "Should render correct tabs") + assertEquals( + "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"active\"><a href=\"#\">ABC</a></li><li role=\"presentation\"><a href=\"#\">DEF</a></li></ul><div><span>abc</span></div></div>", + element?.innerHTML, + "Should render correct tabs" + ) } } @@ -37,7 +41,11 @@ class TabPanelSpec : DomSpec { tabs.addTab("DEF", label2) tabs.activeIndex = 1 val element = document.getElementById("test") - assertEquals("<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"\"><a href=\"#\">ABC</a></li><li role=\"presentation\" class=\"active\"><a href=\"#\">DEF</a></li></ul><div><span>def</span></div></div>", element?.innerHTML, "Should change selected tab") + assertEquals( + "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"\"><a href=\"#\">ABC</a></li><li role=\"presentation\" class=\"active\"><a href=\"#\">DEF</a></li></ul><div><span>def</span></div></div>", + element?.innerHTML, + "Should change selected tab" + ) } } @@ -54,7 +62,11 @@ class TabPanelSpec : DomSpec { tabs.activeIndex = 1 tabs.removeTab(1) val element = document.getElementById("test") - assertEquals("<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"active\"><a href=\"#\">ABC</a></li></ul><div><span>abc</span></div></div>", element?.innerHTML, "Should remove tab") + assertEquals( + "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"active\"><a href=\"#\">ABC</a></li></ul><div><span>abc</span></div></div>", + element?.innerHTML, + "Should remove tab" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt index a65b3ca9..26fb2675 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt @@ -21,7 +21,11 @@ class VPanelSpec : DomSpec { vPanel.add(Label("def"), 2) vPanel.add(Label("ghi"), 3) val element = document.getElementById("test") - assertEquals("<div style=\"display: flex; flex-direction: column; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", element?.innerHTML, "Should render correct vertical panel") + assertEquals( + "<div style=\"display: flex; flex-direction: column; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", + element?.innerHTML, + "Should render correct vertical panel" + ) } } }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt index 3157affc..7ea011ef 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt @@ -24,7 +24,11 @@ class UtilsSpec : SimpleSpec { fun toDateF() { run { val res = "2017-03-14 14:50:35".toDateF() - assertEquals(js("new Date(2017,2,14,14,50,35).getTime()"), res.getTime(), "Should convert String value to Date") + assertEquals( + js("new Date(2017,2,14,14,50,35).getTime()"), + res.getTime(), + "Should convert String value to Date" + ) } } @@ -35,15 +39,15 @@ class UtilsSpec : SimpleSpec { val res = Date().toStringF() val y = date.getFullYear() val m = date.getMonth() + 1 - val m2 = if (m<10) "0$m" else "$m" + val m2 = if (m < 10) "0$m" else "$m" val d = date.getDate() - val d2 = if (d<10) "0$d" else "$d" + val d2 = if (d < 10) "0$d" else "$d" val h = date.getHours() - val h2 = if (h<10) "0$h" else "$h" + val h2 = if (h < 10) "0$h" else "$h" val min = date.getMinutes() - val min2 = if (min<10) "0$min" else "$min" + val min2 = if (min < 10) "0$min" else "$min" val sec = date.getSeconds() - val sec2 = if (sec<10) "0$sec" else "$sec" + val sec2 = if (sec < 10) "0$sec" else "$sec" assertEquals("$y-$m2-$d2 $h2:$min2:$sec2", res, "Should convert Date value to String") } } |