diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-05-09 23:53:57 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-05-09 23:53:57 +0200 |
commit | 134cb687c4e05fd81a03b682505f9fb9d741a8d7 (patch) | |
tree | f9f41f28c01dc29d1d4fdd576cc9b21958fd9c3b /src/main/kotlin/pl/treksoft/kvision/table | |
parent | 4a2aa49e0e561c1bc25aa962449fa2fcce9207ba (diff) | |
download | kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.gz kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.bz2 kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.zip |
Add new className parameter to all DSL builder functions.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/table')
4 files changed, 28 insertions, 10 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt b/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt index 4cf72f77..467f1d1d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Cell.kt @@ -24,6 +24,7 @@ package pl.treksoft.kvision.table import pl.treksoft.kvision.html.Align import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag +import pl.treksoft.kvision.utils.set /** * HTML table cell component. @@ -58,9 +59,11 @@ fun Row.cell( content: String? = null, rich: Boolean = false, align: Align? = null, - classes: Set<String> = setOf(), init: (Cell.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (Cell.() -> Unit)? = null ): Cell { - val cell = Cell(content, rich, align, classes, init) + val cell = Cell(content, rich, align, classes ?: className.set, init) this.add(cell) return cell } @@ -74,9 +77,11 @@ fun Row.thcell( content: String? = null, rich: Boolean = false, align: Align? = null, - classes: Set<String> = setOf(), init: (HeaderCell.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (HeaderCell.() -> Unit)? = null ): HeaderCell { - val headerCell = HeaderCell(content, rich, align, Scope.ROW, classes, init) + val headerCell = HeaderCell(content, rich, align, Scope.ROW, classes ?: className.set, init) this.add(headerCell) return headerCell } diff --git a/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt b/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt index f7f45784..626ab87f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/HeaderCell.kt @@ -24,6 +24,7 @@ package pl.treksoft.kvision.table import pl.treksoft.kvision.html.Align import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag +import pl.treksoft.kvision.utils.set enum class Scope(internal val scope: String) { ROW("row"), @@ -69,9 +70,11 @@ fun Row.headerCell( rich: Boolean = false, align: Align? = null, scope: Scope? = null, - classes: Set<String> = setOf(), init: (HeaderCell.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (HeaderCell.() -> Unit)? = null ): HeaderCell { - val cell = HeaderCell(content, rich, align, scope, classes, init) + val cell = HeaderCell(content, rich, align, scope, classes ?: className.set, init) this.add(cell) return cell } diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Row.kt b/src/main/kotlin/pl/treksoft/kvision/table/Row.kt index 0681953f..a933d38e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Row.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Row.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.table import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag +import pl.treksoft.kvision.utils.set /** * HTML table row component. @@ -46,9 +47,11 @@ open class Row(classes: Set<String> = setOf(), init: (Row.() -> Unit)? = null) : * It takes the same parameters as the constructor of the built component. */ fun Table.row( - classes: Set<String> = setOf(), init: (Row.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (Row.() -> Unit)? = null ): Row { - val row = Row(classes, init) + val row = Row(classes ?: className.set, init) this.add(row) return row } diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt index 6c48157d..56d4a811 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt @@ -29,6 +29,7 @@ import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.panel.SimplePanel +import pl.treksoft.kvision.utils.set import pl.treksoft.kvision.utils.snClasses import pl.treksoft.kvision.utils.snOpt @@ -85,14 +86,17 @@ open class Table( * Table headers names. */ var headerNames by refreshOnUpdate(headerNames) { refreshHeaders() } + /** * Table types. */ var types by refreshOnUpdate(types) + /** * Table caption. */ var caption by refreshOnUpdate(caption) + /** * Determines if the table is responsive. */ @@ -210,10 +214,13 @@ open class Table( fun Container.table( headerNames: List<String>? = null, types: Set<TableType> = setOf(), caption: String? = null, responsiveType: ResponsiveType? = null, - theadType: TheadType? = null, classes: Set<String> = setOf(), init: (Table.() -> Unit)? = null + theadType: TheadType? = null, + classes: Set<String>? = null, + className: String? = null, + init: (Table.() -> Unit)? = null ): Table { val table = - Table(headerNames, types, caption, responsiveType, theadType, classes, init) + Table(headerNames, types, caption, responsiveType, theadType, classes ?: className.set, init) this.add(table) return table } |