52 lines
1.7 KiB
Kotlin
52 lines
1.7 KiB
Kotlin
package be.simplenotes.app.views.components
|
|
|
|
import be.simplenotes.domain.model.PersistedNoteMetadata
|
|
import kotlinx.html.*
|
|
import kotlinx.html.ButtonType.submit
|
|
import kotlinx.html.FormMethod.post
|
|
import kotlinx.html.ThScope.col
|
|
import org.http4k.core.Method
|
|
|
|
fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-auto") {
|
|
table {
|
|
id = "notes"
|
|
thead {
|
|
tr {
|
|
th(col, "w-1/4") { +"Title" }
|
|
th(col, "w-1/4") { +"Updated" }
|
|
th(col, "w-1/4") { +"Tags" }
|
|
th(col, "w-1/4") { +"Restore" }
|
|
}
|
|
}
|
|
tbody {
|
|
notes.forEach { (title, tags, updatedAt, uuid) ->
|
|
tr {
|
|
td { +title }
|
|
td("text-center") { +updatedAt.toString() } // TODO: x time ago
|
|
td { tags(tags) }
|
|
td("text-center") {
|
|
form(classes = "inline", method = post, action = "/notes/deleted/$uuid") {
|
|
button(classes = "btn btn-red", type = submit, name = "delete") {
|
|
+"Delete permanently"
|
|
}
|
|
button(classes = "ml-2 btn btn-green", type = submit, name = "restore") {
|
|
+"Restore"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private fun FlowContent.tags(tags: List<String>) {
|
|
ul("inline flex flex-wrap justify-center") {
|
|
tags.forEach { tag ->
|
|
li("mx-2 my-1") {
|
|
span("tag") { +"#$tag" }
|
|
}
|
|
}
|
|
}
|
|
}
|