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"
|
||||
}
|
||||
|
||||
@@ -2,16 +2,20 @@ package net.keinekekse.app.books.ui
|
||||
|
||||
import kotlinx.html.HTML
|
||||
import net.keinekekse.app.books.db.BookRepository
|
||||
import net.keinekekse.app.books.model.Book
|
||||
import net.keinekekse.app.books.edit.BooksSessionData
|
||||
import net.keinekekse.app.core.auth.UserSession
|
||||
|
||||
fun HTML.bookEditPage(book: Book, booksRepo: BookRepository) {
|
||||
fun HTML.bookEditPage(
|
||||
booksRepo: BookRepository,
|
||||
session: UserSession<BooksSessionData>,
|
||||
) {
|
||||
|
||||
booksPage(
|
||||
navBooksEdit.first,
|
||||
mapOf(navBooks, Pair(navBooksEdit.first, ""))
|
||||
) {
|
||||
|
||||
bookEdit(book, booksRepo)
|
||||
bookEdit(booksRepo, session)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fun HTML.booksPage(booksRepo: BookRepository) {
|
||||
|
||||
}
|
||||
// content right
|
||||
div(classes = "flex flex-auto $bgRightColumn") {
|
||||
div(classes = "flex flex-auto $bgBody") {
|
||||
div(classes = "flex flex-col flex-auto") {
|
||||
// div {
|
||||
// +"some heading"
|
||||
|
||||
@@ -43,7 +43,7 @@ fun HTML.booksPage(title: String, breadcrumbs: Map<String, String>, block: DIV.(
|
||||
|
||||
body {
|
||||
// page
|
||||
div(classes = "$cssFullscreen flex-col") {
|
||||
div(classes = "$cssFullscreen flex-col $textBody") {
|
||||
// header
|
||||
div(classes = "flex flex-row justify-between py-2 px-5 $bgHeader $textHeader") {
|
||||
// header left
|
||||
@@ -80,7 +80,7 @@ fun HTML.booksPage(title: String, breadcrumbs: Map<String, String>, block: DIV.(
|
||||
// }
|
||||
}
|
||||
|
||||
div(classes = "flex flex-row flex-auto overflow-hidden") {
|
||||
div(classes = "flex flex-row flex-auto overflow-hidden $bgBody") {
|
||||
|
||||
block()
|
||||
|
||||
|
||||
@@ -14,15 +14,16 @@ const val textHeader = "text-orange-100"
|
||||
const val bgHeaderIcon = "bg-orange-100"
|
||||
const val bgFooter = "bg-orange-50"
|
||||
|
||||
const val bgLeftColumn = "bg-slate-200"
|
||||
const val bgRightColumn = "bg-slate-50"
|
||||
const val bgThead = "bg-slate-200"
|
||||
|
||||
const val bgBody = "bg-taupe-100"
|
||||
const val textBody = "text-taupe-900"
|
||||
const val bgLeftColumn = "bg-taupe-200"
|
||||
const val bgThead = "bg-taupe-200"
|
||||
const val bgDialogBackdrop = "backdrop:bg-taupe-400/40"
|
||||
const val borderTable = "border-slate-400"
|
||||
|
||||
const val bgStdButton = "bg-taupe-500"
|
||||
const val bgStdButtonHover = "hover:bg-taupe-700"
|
||||
const val bgStdButtonFocus = "focus:bg-taupe-700"
|
||||
const val bgStdButton = "bg-taupe-400"
|
||||
const val bgStdButtonHover = "hover:bg-taupe-500"
|
||||
const val bgStdButtonFocus = "focus:bg-taupe-500"
|
||||
const val bgPriButton = "bg-orange-400"
|
||||
const val bgPriButtonHover = "hover:bg-orange-600"
|
||||
const val bgPriButtonFocus = "focus:bg-orange-600"
|
||||
|
||||
@@ -5,12 +5,18 @@ import kotlinx.html.div
|
||||
import kotlinx.html.img
|
||||
import kotlinx.html.span
|
||||
import net.keinekekse.app.books.db.BookRepository
|
||||
import net.keinekekse.app.books.edit.BooksSessionData
|
||||
import net.keinekekse.app.books.model.Book
|
||||
import net.keinekekse.app.books.model.CalibreBookInfo
|
||||
import net.keinekekse.app.books.model.Languages
|
||||
import net.keinekekse.app.books.model.Publisher
|
||||
import net.keinekekse.app.core.auth.UserSession
|
||||
|
||||
fun HTML.importEditPage(bookInfo: CalibreBookInfo?, booksRepo: BookRepository) {
|
||||
fun HTML.importEditPage(
|
||||
bookInfo: CalibreBookInfo?,
|
||||
booksRepo: BookRepository,
|
||||
session: UserSession<BooksSessionData>,
|
||||
) {
|
||||
val dataUrl = embedImageURL(bookInfo?.cover)
|
||||
booksPage(
|
||||
navBooksScanEdit.first,
|
||||
@@ -18,15 +24,14 @@ fun HTML.importEditPage(bookInfo: CalibreBookInfo?, booksRepo: BookRepository) {
|
||||
) {
|
||||
div(classes = "flex flex-row flex-auto") {
|
||||
|
||||
bookEdit(
|
||||
Book(
|
||||
title = bookInfo?.title ?: "",
|
||||
year = bookInfo?.published ?: 0,
|
||||
isbn = bookInfo?.isbn ?: "",
|
||||
publisher = Publisher(0, ""),
|
||||
language = bookInfo?.language ?: Languages.DE
|
||||
), booksRepo
|
||||
session.data.book = Book(
|
||||
title = bookInfo?.title ?: "",
|
||||
year = bookInfo?.published ?: 0,
|
||||
isbn = bookInfo?.isbn ?: "",
|
||||
publisher = Publisher(0, ""),
|
||||
language = bookInfo?.language ?: Languages.DE
|
||||
)
|
||||
bookEdit(booksRepo, session)
|
||||
|
||||
div(classes = "flex flex-col m-8 ") {
|
||||
div(classes = "text-2xl mx-8") {
|
||||
|
||||
@@ -23,7 +23,7 @@ fun HTML.importPage(books: List<CalibreBookInfo>) {
|
||||
}
|
||||
|
||||
// content right
|
||||
div(classes = "flex flex-auto $bgRightColumn") {
|
||||
div(classes = "flex flex-auto $bgBody") {
|
||||
div(classes = "flex flex-col flex-auto") {
|
||||
div {
|
||||
// +"some heading"
|
||||
|
||||
@@ -211,7 +211,7 @@ fun HTML.testPage(booksDb: Database) {
|
||||
}
|
||||
}
|
||||
// content right
|
||||
div(classes = "flex flex-auto $bgRightColumn") {
|
||||
div(classes = "flex flex-auto $bgBody") {
|
||||
div(classes = "flex flex-col flex-auto") {
|
||||
// div {
|
||||
// +"some heading"
|
||||
|
||||
Reference in new issue
Block a user