Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
revert TodoApp change while debugging what went wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jun 14, 2021
1 parent 726b136 commit f4059ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
25 changes: 12 additions & 13 deletions src/main/kotlin/kweb/demos/todo/TodoApp.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package kweb.demos.todo

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.await
import kotlinx.coroutines.launch
import kotlinx.serialization.json.jsonPrimitive
import kweb.*
import kweb.plugins.fomanticUI.fomantic
import kweb.plugins.fomanticUI.fomanticUIPlugin
Expand Down Expand Up @@ -143,25 +141,26 @@ class TodoApp {
}
div(fomantic.ui.action.input) {
val input = input(type = InputType.text, placeholder = "Add Item")
// Note that an event can optionally evaluate a javascript expression and retrieve the
// result, which is supplied to the event handler in event.retrieved.
input.on(retrieveJs = input.valueJsExpression).keypress { event ->
if (event.code == "Enter") {
handleAddItem(input, list, event.retrieved.jsonPrimitive.content)
input.on.keypress { ke ->
if (ke.code == "Enter") {
handleAddItem(input, list)
}
}
button(fomantic.ui.button).text("Add").apply {
on(retrieveJs = input.valueJsExpression).click { event ->
handleAddItem(input, list, event.retrieved.jsonPrimitive.content)
on.click {
handleAddItem(input, list)
}
}
}
}

private fun handleAddItem(input: InputElement, list: KVar<ToDoState.List>, newItemText: String) {
input.setValue("")
val newItem = ToDoState.Item(generateNewUid(), System.currentTimeMillis(), list.value.uid, newItemText)
state.items[newItem.uid] = newItem
private fun handleAddItem(input: InputElement, list: KVar<ToDoState.List>) {
GlobalScope.launch {
val newItemText = input.getValue()
input.setValue("")
val newItem = ToDoState.Item(generateNewUid(), System.currentTimeMillis(), list.value.uid, newItemText)
state.items[newItem.uid] = newItem
}
}

private fun ElementCreator<DivElement>.renderRemoveButton(item: KVar<ToDoState.Item>) {
Expand Down
36 changes: 18 additions & 18 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<configuration>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>

<logger name="kweb" level="debug">
<appender-ref ref="CONSOLE"/>
</logger>

<root level="warn">
<appender-ref ref="CONSOLE"/>
</root>

<configuration debug="true">

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>

<logger name="kweb" level="debug">
<appender-ref ref="CONSOLE"/>
</logger>

<root level="warn">
<appender-ref ref="CONSOLE"/>
</root>

</configuration>

0 comments on commit f4059ab

Please sign in to comment.