progress
This commit is contained in:
1 parent
8976e25499
commit
e08a941c62
15 files changed
+223
-103
No files matched your search
@@ -4,21 +4,26 @@ import io.ktor.htmx.html.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.html.*
|
||||
import net.keinekekse.app.books.db.BookRepository
|
||||
import net.keinekekse.app.books.model.*
|
||||
import net.keinekekse.app.books.model.Tag
|
||||
import net.keinekekse.app.books.edit.BooksSessionData
|
||||
import net.keinekekse.app.books.model.BookType
|
||||
import net.keinekekse.app.books.model.Languages
|
||||
import net.keinekekse.app.core.auth.UserSession
|
||||
|
||||
fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
fun FlowContent.bookEdit(
|
||||
booksRepo: BookRepository,
|
||||
session: UserSession<BooksSessionData>,
|
||||
) {
|
||||
|
||||
val publishers: List<Publisher> = runBlocking {
|
||||
session.data.publisherList = runBlocking {
|
||||
booksRepo.allPublishers()
|
||||
}
|
||||
val series: List<Series> = runBlocking {
|
||||
session.data.seriesList = runBlocking {
|
||||
booksRepo.allSeries()
|
||||
}
|
||||
val artists: List<Artist> = runBlocking {
|
||||
session.data.artistList = runBlocking {
|
||||
booksRepo.allArtists()
|
||||
}
|
||||
val tags: List<Tag> = runBlocking {
|
||||
session.data.tagList = runBlocking {
|
||||
booksRepo.allTags()
|
||||
}
|
||||
|
||||
@@ -29,8 +34,11 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
target = "#response"
|
||||
swap = "innerHTML"
|
||||
}
|
||||
input(type = InputType.hidden, name = "sessionId") {
|
||||
value = session.sessionId
|
||||
}
|
||||
input(type = InputType.hidden, name = "bookId") {
|
||||
value = book.id.toString()
|
||||
value = session.data.book.id.toString()
|
||||
}
|
||||
|
||||
div(classes = "flex flex-row mb-5 h-9") {
|
||||
@@ -43,7 +51,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
|
||||
for (type in BookType.entries) {
|
||||
option {
|
||||
if (type == book.type)
|
||||
if (type == session.data.book.type)
|
||||
selected = true
|
||||
value = type.ordinal.toString()
|
||||
+type.name
|
||||
@@ -57,7 +65,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-150") {
|
||||
name = "title"
|
||||
value = book.title
|
||||
value = session.data.book.title
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +75,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-150") {
|
||||
name = "originaltitle"
|
||||
value = book.originalTitle ?: ""
|
||||
value = session.data.book.originalTitle ?: ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,7 +85,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-150") {
|
||||
name = "subtitle"
|
||||
value = book.subTitle ?: ""
|
||||
value = session.data.book.subTitle ?: ""
|
||||
}
|
||||
}
|
||||
div(classes = "flex flex-row mb-5 h-9") {
|
||||
@@ -89,7 +97,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
|
||||
for (language in Languages.entries) {
|
||||
option {
|
||||
if (language == book.language)
|
||||
if (language == session.data.book.language)
|
||||
selected = true
|
||||
value = language.ordinal.toString()
|
||||
+language.name
|
||||
@@ -102,7 +110,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-16") {
|
||||
name = "year"
|
||||
value = book.year.toString()
|
||||
value = session.data.book.year.toString()
|
||||
}
|
||||
|
||||
div(classes = "ml-8 pr-3 content-center") {
|
||||
@@ -110,7 +118,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-16") {
|
||||
name = "originalyear"
|
||||
value = book.originalYear?.toString() ?: ""
|
||||
value = session.data.book.originalYear?.toString() ?: ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,7 +128,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-40") {
|
||||
name = "isbn"
|
||||
value = book.isbn
|
||||
value = session.data.book.isbn
|
||||
}
|
||||
|
||||
div(classes = "ml-14 pr-3 content-center") {
|
||||
@@ -133,9 +141,9 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
value = "0"
|
||||
+"---"
|
||||
}
|
||||
for (pub in publishers) {
|
||||
for (pub in session.data.publisherList) {
|
||||
option {
|
||||
if (pub.id == book.publisher.id)
|
||||
if (pub.id == session.data.book.publisher.id)
|
||||
selected = true
|
||||
value = pub.id.toString()
|
||||
+pub.name
|
||||
@@ -145,9 +153,15 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
button(classes = cssFormIcon) {
|
||||
title = "Verlag hinzufügen"
|
||||
// TODO
|
||||
onClick = "document.getElementById('publisherDialog').showModal()"
|
||||
// attributes["command"] = "show-modal"
|
||||
// attributes["commandfor"] = "publisherDialog" //id
|
||||
/*
|
||||
type = ButtonType.button -> sonst wird "submit" angenommen und dann funktioniert
|
||||
es nicht!
|
||||
*/
|
||||
type = ButtonType.button
|
||||
// attributes["popovertarget"] = "publisherDialog"
|
||||
// onClick = "document.getElementById('publisherDialog').showModal()"
|
||||
attributes["command"] = "show-modal"
|
||||
attributes["commandfor"] = "publisherDialog" //id
|
||||
|
||||
materialSymbolFormButton("add_box")
|
||||
}
|
||||
@@ -165,9 +179,9 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
value = "0"
|
||||
+"---"
|
||||
}
|
||||
for (serie in series) {
|
||||
for (serie in session.data.seriesList) {
|
||||
option {
|
||||
if (book.series != null && serie.id == book.series.id)
|
||||
if (session.data.book.series != null && serie.id == session.data.book.series!!.id)
|
||||
selected = true
|
||||
value = serie.id.toString()
|
||||
+serie.name
|
||||
@@ -184,7 +198,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
input(classes = "$cssTextInput w-16") {
|
||||
name = "seriesindex"
|
||||
value = book.seriesIndex?.toString() ?: ""
|
||||
value = session.data.book.seriesIndex?.toString() ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +223,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
tbody {
|
||||
|
||||
for ((artist, role) in book.artists) {
|
||||
for ((artist, role) in session.data.book.artists) {
|
||||
tr {
|
||||
td(classes = "border-t-1 $borderTable px-2 py-1") {
|
||||
+"${artist.name}, ${artist.givenName}"
|
||||
@@ -249,7 +263,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
for (tag in book.tags) {
|
||||
for (tag in session.data.book.tags) {
|
||||
tr {
|
||||
td(classes = "border-t-1 $borderTable px-2 py-1") {
|
||||
+tag.tag
|
||||
@@ -273,7 +287,7 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
textArea(classes = "$cssTextInput w-150 h-18 resize-none") {
|
||||
name = "comment"
|
||||
spellCheck = true
|
||||
+book.comments
|
||||
+session.data.book.comments
|
||||
}
|
||||
}
|
||||
// TODO parent
|
||||
@@ -295,13 +309,23 @@ fun FlowContent.bookEdit(book: Book, booksRepo: BookRepository) {
|
||||
}
|
||||
|
||||
// TODO
|
||||
dialog {
|
||||
dialog(
|
||||
classes = "m-auto h-fit w-full max-w-md rounded-lg shadow-2xl border-2 " +
|
||||
"$borderTable px-3 py-2 $bgBody $textBody $bgDialogBackdrop"
|
||||
) {
|
||||
id = "publisherDialog"
|
||||
attributes["closedby"] = "any"
|
||||
// attributes["popover"] = "true"
|
||||
// attributes["closedby"] = "any"
|
||||
div {
|
||||
+"Test-Verlag"
|
||||
}
|
||||
button(classes = cssButtonStd) {
|
||||
attributes["commandfor"] = "publisherDialog"
|
||||
attributes["command"] = "close"
|
||||
+"Close"
|
||||
}
|
||||
}
|
||||
output { }
|
||||
div {
|
||||
id = "response"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user