diff options
4 files changed, 55 insertions, 6 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index b4abad0c..a0ea6881 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -110,6 +110,12 @@ class Showcase : ApplicationBase() { val select5 = Select(listOf("a" to "Pierwsza", "b" to "Druga"), "a", label = "Lista wyboru") root.add(select5) + val select6 = Select(label = "Lista wyboru 2") + select6.add(SelectOption("a", "Opcja 1")) + select6.add(SelectOption("b", "Opcja 2")) + select6.add(SelectOption("c", "Opcja 3")) + root.add(select6) + val container = SimplePanel(setOf("abc", "def")) val h1 = Tag(H1, "To jest <i>test pisania</i> tekstu", false, null, classes = setOf("test", "test2")) container.add(h1) diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index 3b6d3aa8..5af2eb66 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -7,8 +7,8 @@ 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()) : + private val binding: (M, Int) -> C, + private val child: Container = VPanel()) : Widget(setOf()), Container, DataUpdatable { override var visible @@ -26,19 +26,23 @@ class DataContainer<M : DataComponent, C : Widget>(val model: ObservableList<M>, } override fun add(child: Widget): Container { - return this.child.add(child) + this.child.add(child) + return this } override fun addAll(children: List<Widget>): Container { - return this.child.addAll(children) + this.child.addAll(children) + return this } override fun remove(child: Widget): Container { - return this.child.remove(child) + this.child.remove(child) + return this } override fun removeAll(): Container { - return this.child.removeAll() + this.child.removeAll() + return this } override fun getChildren(): List<Widget> { diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index eabed092..ade2937b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -97,6 +97,21 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri return this } + override fun remove(child: Widget): SimplePanel { + list.remove(child) + return this + } + + override fun removeAll(): SimplePanel { + list.removeAll() + return this + } + + override fun getChildren(): List<Widget> { + return list.getChildren() + } + + private fun setChildrenFromElements() { list.removeAll() elements?.let { elems -> diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/Select.kt index 413178d2..a8759208 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Select.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Select.kt @@ -119,4 +119,28 @@ open class Select(options: List<StringPair>? = null, value: String? = null, input.removeEventListeners() return this } + + override fun add(child: Widget): SimplePanel { + input.add(child) + return this + } + + override fun addAll(children: List<Widget>): SimplePanel { + input.addAll(children) + return this + } + + override fun remove(child: Widget): SimplePanel { + input.remove(child) + return this + } + + override fun removeAll(): SimplePanel { + input.removeAll() + return this + } + + override fun getChildren(): List<Widget> { + return input.getChildren() + } } |