From 134cb687c4e05fd81a03b682505f9fb9d741a8d7 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 9 May 2020 23:53:57 +0200 Subject: Add new className parameter to all DSL builder functions. --- .../kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'kvision-modules/kvision-tabulator') diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt index 0292a0a4..d830f8a2 100644 --- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt +++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt @@ -33,6 +33,7 @@ import pl.treksoft.kvision.state.ObservableState import pl.treksoft.kvision.table.TableType import pl.treksoft.kvision.utils.createInstance import pl.treksoft.kvision.utils.obj +import pl.treksoft.kvision.utils.set import pl.treksoft.kvision.utils.syncWithList import kotlin.browser.window import pl.treksoft.kvision.tabulator.js.Tabulator as JsTabulator @@ -739,10 +740,11 @@ fun Container.tabulator( dataUpdateOnEdit: Boolean = true, options: TabulatorOptions = TabulatorOptions(), types: Set = setOf(), - classes: Set = setOf(), + classes: Set? = null, + className: String? = null, init: (Tabulator.() -> Unit)? = null ): Tabulator { - val tabulator = Tabulator.create(data, dataUpdateOnEdit, options, types, classes) + val tabulator = Tabulator.create(data, dataUpdateOnEdit, options, types, classes ?: className.set) init?.invoke(tabulator) this.add(tabulator) return tabulator @@ -756,10 +758,11 @@ fun Container.tabulator( dataFactory: (S) -> List, options: TabulatorOptions = TabulatorOptions(), types: Set = setOf(), - classes: Set = setOf(), + classes: Set? = null, + className: String? = null, init: (Tabulator.() -> Unit)? = null ): Tabulator { - val tabulator = Tabulator.create(store, dataFactory, options, types, classes) + val tabulator = Tabulator.create(store, dataFactory, options, types, classes ?: className.set) init?.invoke(tabulator) this.add(tabulator) return tabulator @@ -771,10 +774,12 @@ fun Container.tabulator( fun Container.tabulator( options: TabulatorOptions = TabulatorOptions(), types: Set = setOf(), - classes: Set = setOf(), + classes: Set? = null, + className: String? = null, init: (Tabulator.() -> Unit)? = null ): Tabulator { - val tabulator = Tabulator(dataUpdateOnEdit = false, options = options, types = types, classes = classes) + val tabulator = + Tabulator(dataUpdateOnEdit = false, options = options, types = types, classes = classes ?: className.set) init?.invoke(tabulator) this.add(tabulator) return tabulator -- cgit