diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-11 23:36:01 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-11 23:45:06 +0100 |
commit | c0fca9901a634d53d8ee0bfb119b9b2e2f017d83 (patch) | |
tree | 127bbc1cd56097694d906d9b9245164436457a76 /src/main | |
parent | 3577c10b5c3839a06f64cb19e72788401bd7406d (diff) | |
download | kvision-c0fca9901a634d53d8ee0bfb119b9b2e2f017d83.tar.gz kvision-c0fca9901a634d53d8ee0bfb119b9b2e2f017d83.tar.bz2 kvision-c0fca9901a634d53d8ee0bfb119b9b2e2f017d83.zip |
Change the name of content property in Tag component.
Diffstat (limited to 'src/main')
20 files changed, 83 insertions, 81 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt index b4be8f8e..e6aad194 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt @@ -30,16 +30,16 @@ import pl.treksoft.kvision.html.Tag * * @constructor * @param forId the value of *for* attribute - * @param text the text of the label - * @param rich determines if [text] can contain HTML code + * @param content the text of the label + * @param rich determines if [content] can contain HTML code * @param classes a set of CSS class names */ open class FieldLabel( - internal val forId: String, text: String? = null, rich: Boolean = false, + internal val forId: String, content: String? = null, rich: Boolean = false, classes: Set<String> = setOf("control-label") ) : Tag( TAG.LABEL, - text, rich, classes = classes + content, rich, classes = classes ) { override fun getSnAttrs(): List<StringPair> { diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt index b74ae533..41d964fd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt @@ -86,9 +86,9 @@ interface FormControl : Component { * Validator error message. */ var validatorError: String? - get() = validationInfo.text + get() = validationInfo.content set(value) { - validationInfo.text = value + validationInfo.content = value validationInfo.visible = value != null refresh() } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt index 5df2d299..1be29f31 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt @@ -73,9 +73,9 @@ open class FormPanel<K>( } internal var validatorError: String? - get() = validationAlert.text + get() = validationAlert.content set(value) { - validationAlert.text = value + validationAlert.content = value validationAlert.visible = value != null refresh() } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt b/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt index db9aebc5..9ec3d8ae 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/HelpBlock.kt @@ -28,10 +28,10 @@ import pl.treksoft.kvision.html.Tag * Helper class for Bootstrap help block element. * * @constructor - * @param text the text of the label - * @param rich determines if [text] can contain HTML code + * @param content the text of the label + * @param rich determines if [content] can contain HTML code */ -open class HelpBlock(text: String? = null, rich: Boolean = false) : Tag( - TAG.SPAN, text, rich, +open class HelpBlock(content: String? = null, rich: Boolean = false) : Tag( + TAG.SPAN, content, 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 f1d231c6..58033d3a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -92,9 +92,9 @@ open class CheckBox( * The label text bound to the input element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 5b02938c..6e26fa5b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -102,9 +102,9 @@ open class Radio( * The label text bound to the input element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 2ed8a36c..84e3d89f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -75,9 +75,9 @@ open class RadioGroup( * The label text of the options group. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 8d443ecf..0c9cdb2e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt @@ -166,9 +166,9 @@ open class Select( * The label text bound to the select element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 0aa514b7..9d72f36b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -159,9 +159,9 @@ open class Spinner( * The label text bound to the spinner input element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 1d3b5e01..3c62d4a8 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt @@ -107,9 +107,9 @@ abstract class AbstractText(label: String? = null, rich: Boolean = false) : * The label text bound to the text input element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. 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 dd6f222d..ecf930e2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt @@ -158,9 +158,9 @@ open class DateTime( * The label text bound to the input element. */ var label - get() = flabel.text + get() = flabel.content set(value) { - flabel.text = value + flabel.content = value } /** * Determines if [label] can contain HTML code. diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt index 38dc5817..6d8e05ef 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Div.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Div.kt @@ -27,17 +27,17 @@ import pl.treksoft.kvision.core.Container * Simple component rendered as *div*. * * @constructor - * @param text element text - * @param rich determines if [text] can contain HTML code + * @param content element text + * @param rich determines if [content] can contain HTML code */ open class Div( - text: String, + content: String, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Div.() -> Unit)? = null ) : - Tag(TAG.DIV, text, rich, align, classes) { + Tag(TAG.DIV, content, rich, align, classes) { init { @Suppress("LeakingThis") @@ -51,13 +51,13 @@ open class Div( * It takes the same parameters as the constructor of the built component. */ fun Container.div( - text: String, + content: String, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Div.() -> Unit)? = null ): Div { - val div = Div(text, rich, align, classes).apply { init?.invoke(this) } + val div = Div(content, rich, align, classes).apply { init?.invoke(this) } this.add(div) return div } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Label.kt b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt index e56362ef..2ec45274 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Label.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt @@ -27,10 +27,10 @@ import pl.treksoft.kvision.core.Container * Simple label component rendered as *span*. * * @constructor - * @param text label text - * @param rich determines if [text] can contain HTML code + * @param content label text + * @param rich determines if [content] can contain HTML code */ -open class Label(text: String, rich: Boolean = false) : Tag(TAG.SPAN, text, rich) { +open class Label(content: String, rich: Boolean = false) : Tag(TAG.SPAN, content, rich) { companion object { /** * DSL builder extension function. @@ -38,9 +38,9 @@ open class Label(text: String, rich: Boolean = false) : Tag(TAG.SPAN, text, rich * It takes the same parameters as the constructor of the built component. */ fun Container.label( - text: String, rich: Boolean = false, init: (Label.() -> Unit)? = null + content: String, rich: Boolean = false, init: (Label.() -> Unit)? = null ): Label { - val label = Label(text, rich).apply { init?.invoke(this) } + val label = Label(content, rich).apply { init?.invoke(this) } this.add(label) return label } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index 78cde306..fce5acaa 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -74,7 +74,9 @@ enum class TAG(internal val tagName: String) { TH("th"), TBODY("tbody"), TR("tr"), - TD("td") + TD("td"), + + FORM("form") } /** @@ -93,14 +95,14 @@ enum class Align(val className: String) { * * @constructor * @param type tag type - * @param text text content of the tag - * @param rich determines if [text] can contain HTML code - * @param align text align + * @param content content text of the tag + * @param rich determines if [content] can contain HTML code + * @param align content align * @param classes a set of CSS class names * @param init an initializer extension function */ open class Tag( - type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null, + type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ) : SimplePanel(classes) { @@ -111,9 +113,9 @@ open class Tag( /** * Text content of the tag. */ - var text by refreshOnUpdate(text) + var content by refreshOnUpdate(content) /** - * Determines if [text] can contain HTML code. + * Determines if [content] can contain HTML code. */ var rich by refreshOnUpdate(rich) /** @@ -127,11 +129,11 @@ open class Tag( } override fun render(): VNode { - return if (text != null) { + return if (content != null) { if (rich) { - render(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>")) + childrenVNodes()) + render(type.tagName, arrayOf(KVManager.virtualize("<span>$content</span>")) + childrenVNodes()) } else { - render(type.tagName, childrenVNodes() + arrayOf(text)) + render(type.tagName, childrenVNodes() + arrayOf(content)) } } else { render(type.tagName, childrenVNodes()) @@ -153,10 +155,10 @@ open class Tag( * It takes the same parameters as the constructor of the built component. */ fun Container.tag( - type: TAG, text: String? = null, rich: Boolean = false, align: Align? = null, + type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ): Tag { - val tag = Tag(type, text, rich, align, classes, init) + val tag = Tag(type, content, rich, align, classes, init) this.add(tag) return tag } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt index de5bcd3b..5f5a1a80 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt @@ -51,31 +51,31 @@ open class Alert( * Window content text. */ var text - get() = content.text + get() = contentTag.content set(value) { - content.text = value + contentTag.content = value } /** * Determines if [text] can contain HTML code. */ var rich - get() = content.rich + get() = contentTag.rich set(value) { - content.rich = value + contentTag.rich = value } /** * Text align. */ var align - get() = content.align + get() = contentTag.align set(value) { - content.align = value + contentTag.align = value } - private val content = Tag(TAG.DIV, text, rich, align) + private val contentTag = Tag(TAG.DIV, text, rich, align) init { - body.add(content) + body.add(contentTag) val okButton = Button("OK", "ok", ButtonStyle.PRIMARY) okButton.setEventListener { click = { diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt index 55310d50..ffd67a1b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt @@ -52,36 +52,36 @@ open class Confirm( * Window content text. */ var text - get() = content.text + get() = contentTag.content set(value) { - content.text = value + contentTag.content = value } /** * Determines if [text] can contain HTML code. */ var rich - get() = content.rich + get() = contentTag.rich set(value) { - content.rich = value + contentTag.rich = value } /** * Text align. */ var align - get() = content.align + get() = contentTag.align set(value) { - content.align = value + contentTag.align = value } /** * Determines if Cancel button is visible. */ var cancelVisible by refreshOnUpdate(cancelVisible, { refreshCancelButton() }) - private val content = Tag(TAG.DIV, text, rich, align) + private val contentTag = Tag(TAG.DIV, text, rich, align) private val cancelButton = Button("Cancel", "remove") init { - body.add(content) + body.add(contentTag) cancelButton.setEventListener { click = { hide() diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index 8e434d73..b77e8e2e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -64,9 +64,9 @@ open class Modal( * Window caption text. */ var caption - get() = captionTag.text + get() = captionTag.content set(value) { - captionTag.text = value + captionTag.content = value checkHeaderVisibility() } /** diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt b/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt index 8ea26327..7a0874d6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt @@ -11,19 +11,19 @@ import pl.treksoft.kvision.html.Tag * HTML table cell component. * * @constructor - * @param text text content of the cell - * @param rich determines if [text] can contain HTML code + * @param content text content of the cell + * @param rich determines if [content] can contain HTML code * @param align text align * @param classes a set of CSS class names * @param init an initializer extension function */ open class Cell( - text: String? = null, + content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Cell.() -> Unit)? = null -) : Tag(TAG.TD, text, rich, align, classes) { +) : Tag(TAG.TD, content, rich, align, classes) { init { @Suppress("LeakingThis") @@ -37,12 +37,12 @@ open class Cell( * It takes the same parameters as the constructor of the built component. */ fun Row.cell( - text: String? = null, + content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (Cell.() -> Unit)? = null ): Cell { - val cell = Cell(text, rich, align, classes, init) + val cell = Cell(content, rich, align, classes, init) this.add(cell) return cell } diff --git a/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt b/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt index d6ab2c18..dcca1ea9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt @@ -11,19 +11,19 @@ import pl.treksoft.kvision.html.Tag * HTML table header cell component. * * @constructor - * @param text text content of the cell - * @param rich determines if [text] can contain HTML code + * @param content text content of the cell + * @param rich determines if [content] can contain HTML code * @param align text align * @param classes a set of CSS class names * @param init an initializer extension function */ open class HeaderCell( - text: String? = null, + content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (HeaderCell.() -> Unit)? = null -) : Tag(TAG.TH, text, rich, align, classes) { +) : Tag(TAG.TH, content, rich, align, classes) { init { @Suppress("LeakingThis") @@ -37,12 +37,12 @@ open class HeaderCell( * It takes the same parameters as the constructor of the built component. */ fun Row.headerCell( - text: String? = null, + content: String? = null, rich: Boolean = false, align: Align? = null, classes: Set<String> = setOf(), init: (HeaderCell.() -> Unit)? = null ): HeaderCell { - val cell = HeaderCell(text, rich, align, classes, init) + val cell = HeaderCell(content, rich, align, classes, init) this.add(cell) return cell } diff --git a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt index 1225a1c2..728eff38 100644 --- a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt +++ b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt @@ -71,9 +71,9 @@ open class Window( * Window caption text. */ var caption - get() = captionTag.text + get() = captionTag.content set(value) { - captionTag.text = value + captionTag.content = value checkHeaderVisibility() } /** |