This commit is contained in:
Hartmut Bauer committed 2026-10-11 01:06:16 +02:00
1 parent d84861949f
commit b6c68f5045
14 files changed
+296 -49

No files matched your search

+89 -24
View File
@@ -22,6 +22,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
booksRepo.allTags()
}
var tabCount = 1
div(classes = "flex flex-col m-8") {
form {
attributes.hx {
@@ -31,44 +32,62 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30 ") {
div(classes = "w-30 content-center") {
+"Typ"
}
select(classes = "$cssTextInput w-40") {
name = "type"
tabIndex = tabCount++.toString()
for (type in BookType.entries) {
option {
if (type == book.type)
selected = true
value = type.ordinal.toString()
+type.name
}
}
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30 content-center") {
+"Titel:"
}
input(classes = "$cssTextInput w-150") {
name = "title"
tabIndex = "1"
tabIndex = tabCount++.toString()
value = book.title
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30 ") {
div(classes = "w-30 content-center") {
+"Originaltitel:"
}
input(classes = "$cssTextInput w-150") {
name = "originaltitle"
tabIndex = "2"
tabIndex = tabCount++.toString()
value = book.originalTitle ?: ""
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30 ") {
div(classes = "w-30 content-center") {
+"Untertitel:"
}
input(classes = "$cssTextInput w-150") {
name = "subtitle"
tabIndex = "3"
tabIndex = tabCount++.toString()
value = book.subTitle ?: ""
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30") {
div(classes = "w-30 content-center") {
+"Sprache"
}
select(classes = "$cssTextInput w-16") {
name = "language"
tabIndex = "4"
tabIndex = tabCount++.toString()
for (language in Languages.entries) {
option {
@@ -80,41 +99,41 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
}
}
div(classes = "ml-9 pr-3 ") {
div(classes = "ml-9 pr-3 content-center") {
+"Erscheinungsjahr:"
}
input(classes = "$cssTextInput w-16") {
name = "year"
tabIndex = "5"
tabIndex = tabCount++.toString()
value = book.year.toString()
}
div(classes = "ml-8 pr-3") {
div(classes = "ml-8 pr-3 content-center") {
+"Jahr der Originalausgabe:"
}
input(classes = "$cssTextInput w-16") {
name = "originalyear"
tabIndex = "6"
tabIndex = tabCount++.toString()
value = book.originalYear?.toString() ?: ""
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30") {
div(classes = "w-30 content-center") {
+"ISBN"
}
input(classes = "$cssTextInput w-40") {
name = "isbn"
tabIndex = "7"
tabIndex = tabCount++.toString()
value = book.isbn
}
div(classes = "ml-14 pr-3") {
div(classes = "ml-14 pr-3 content-center") {
+"Verlag"
}
select(classes = "$cssTextInput w-74") {
name = "publisher"
tabIndex = "8"
tabIndex = tabCount++.toString()
option {
value = "0"
@@ -130,7 +149,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
}
}
a(classes = cssFormIcon) {
tabIndex = "9"
tabIndex = tabCount++.toString()
title = "Verlag hinzufügen"
materialSymbolFormButton("add_box")
}
@@ -138,12 +157,12 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "w-30") {
div(classes = "w-30 content-center") {
+"Serie"
}
select(classes = "$cssTextInput w-98") {
name = "series"
tabIndex = "10"
tabIndex = tabCount++.toString()
option {
value = "0"
@@ -159,22 +178,68 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
}
}
a(classes = cssFormIcon) {
tabIndex = "11"
tabIndex = tabCount++.toString()
title = "Serie hinzufügen"
materialSymbolFormButton("add_box")
}
div(classes = "ml-13 pr-3 ") {
div(classes = "ml-13 pr-3 content-center") {
+"Index"
}
input(classes = "$cssTextInput w-16") {
name = "seriesindex"
tabIndex = "12"
tabIndex = tabCount++.toString()
value = book.seriesIndex?.toString() ?: ""
}
}
div(classes = "flex flex-row mb-5 h-9") {
div(classes = "flex flex-row mb-5") {
div(classes = "w-30 content-center") {
+"Künstler"
}
div(classes = "overflow-auto px-1 pb-1 h-40") {
table {
thead(classes = "$cssFixedTHead ") {
tr {
th(classes = "py-3 px-2") { +"Name" }
th(classes = "py-3 px-2") { +"Rolle" }
th(classes = "py-3 px-2") {
a(classes = cssFormIcon) {
tabIndex = tabCount++.toString()
title = "Künstler hinzufügen"
materialSymbolFormButton("add_box")
}
}
}
}
tbody {
for ((artist, role) in book.artists) {
tr {
td(classes = "border-t-1 $borderTable px-2 py-1") {
+"${artist.name}, ${artist.givenName}"
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+role.role
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
a(classes = cssFormIcon) {
tabIndex = tabCount++.toString()
// href = "${navBooksEdit.second}/${book.id}"
materialSymbolFormButton("Edit")
}
a(classes = cssFormIcon) {
tabIndex = tabCount++.toString()
materialSymbolFormButton("Delete")
}
}
}
}
}
}
}
// artists tags
// | | | |
// | | | |
@@ -190,7 +255,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
button(classes = "$cssButtonPri block mt-8") {
tabIndex = "20"
tabIndex = tabCount++.toString()
type = ButtonType.submit
+"Save"
}
@@ -0,0 +1,17 @@
package net.keinekekse.app.books.ui
import kotlinx.html.HTML
import net.keinekekse.app.books.db.BookRepository
import net.keinekekse.app.books.model.Book
fun HTML.bookEditPage(book: Book, booksRepo: BookRepository) {
booksPage(
navBooksEdit.first,
mapOf(navBooks, Pair(navBooksEdit.first, ""))
) {
bookEdit(book, booksRepo)
}
}
@@ -0,0 +1,112 @@
package net.keinekekse.app.books.ui
import kotlinx.coroutines.runBlocking
import kotlinx.html.*
import net.keinekekse.app.books.db.BookRepository
import net.keinekekse.app.books.model.Book
fun HTML.booksPage(booksRepo: BookRepository) {
booksPage("Books-DB", mapOf(Pair(navBooks.first, ""))) {
// content left
div(classes = "basis-64 px-1 py-2 text-center $bgLeftColumn") {
div {
+"some content on the left "
}
}
// content right
div(classes = "flex flex-auto $bgRightColumn") {
div(classes = "flex flex-col flex-auto") {
// div {
// +"some heading"
// }
booksTable(booksRepo)
}
}
}
}
fun FlowContent.booksTable(booksRepo: BookRepository) {
val books: List<Book> = runBlocking {
booksRepo.allBooks()
}
div(classes = "flex-auto overflow-auto px-1 pb-1") {
table {
id = "bookstable"
thead(classes = "$cssFixedTHead ") {
tr {
th(classes = "py-3 px-2") { +"Titel" }
th(classes = "py-3 px-2") { +"Autor(en)" }
th(classes = "py-3 px-2") { +"Serie" }
th(classes = "py-3 px-2") { +"Sprache" }
th(classes = "py-3 px-2") { +"Jahr" }
th(classes = "py-3 px-2") { +"Typ" }
th(classes = "py-3 px-2") { +"Gelesen" }
th(classes = "py-3 px-2") {
a {
href = navBooksNew.second
title = navBooksNew.first
materialSymbolButton(
"auto_stories",
"font-weight: bold; font-size: 2em"
)
// library_add
}
}
}
}
tbody {
for (book in books) {
tr {
td(classes = "border-t-1 $borderTable px-2 py-1") {
+book.title
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+artistsString(book, 40)
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+(book.series?.name ?: "") // TODO add index
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+book.language.name
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+book.year.toString()
}
td(classes = "border-t-1 $borderTable px-2 py-1") {
+book.type.name
}
td(classes = "border-t-1 $borderTable px-2 py-1 text-center text-slate-400") {
title = if (book.read) "gelesen" else "ungelesen"
if (book.read) materialSymbol("check_small") //check_small || check_circle
else materialSymbol("close_small") //cancel || close || block
}
td(classes = "border-t-1 $borderTable px-2 py-1 text-nowrap") {
a {
title = if (book.read) "ungelesen" else "gelesen"
materialSymbolButton("published_with_changes")
}
a {
href = "${navBooksEdit.second}/${book.id}"
materialSymbolButton("Edit")
}
materialSymbolButton("Delete")
}
}
}
}
}
}
}
fun artistsString(book: Book, len: Int = 0): String {
val rc = book.artists.joinToString(" & ") { it.artist.toString() }
return if (rc.length > len) rc.slice(0..len) else rc
}
@@ -51,6 +51,7 @@ fun HTML.booksPage(title: String, breadcrumbs: Map<String, String>, block: DIV.(
programName()
div(classes = "ml-10 flex self-end pr-5 pt-2 border-t-1 items-baseline") {
a(classes = cssHeaderLink) {
tabIndex = "0"
href = "/"
materialSymbol("home")
// +"Start"
@@ -60,6 +61,7 @@ fun HTML.booksPage(title: String, breadcrumbs: Map<String, String>, block: DIV.(
breadcrumbs.forEach { (name, url) ->
if (url.isNotEmpty()) {
a(classes = cssHeaderLink) {
tabIndex = "0"
href = url
+name
}
@@ -3,6 +3,7 @@ package net.keinekekse.app.books.ui
import io.ktor.util.logging.*
import net.keinekekse.app.books.db.BookRepository
import net.keinekekse.app.books.db.schema.*
import net.keinekekse.app.books.model.BookType
import net.keinekekse.app.books.model.Languages
import org.jetbrains.exposed.v1.jdbc.Database
import org.jetbrains.exposed.v1.jdbc.SchemaUtils
@@ -85,6 +86,8 @@ suspend fun dbTest(db: Database, booksRepo: BookRepository) {
language = Languages.EN
isbn = "9781617296823"
publisher = pub1
type = BookType.BUCH
read = true
comments = ""
}
val kp = BookDAO.new {
@@ -97,6 +100,7 @@ suspend fun dbTest(db: Database, booksRepo: BookRepository) {
language = Languages.EN
isbn = "9781617298823"
publisher = pub2
type = BookType.BUCH
comments = ""
}