Show deleted notes count
This commit is contained in:
parent
a98d6e8e64
commit
8ccd7f6058
@ -48,7 +48,8 @@ class NoteController(
|
||||
val currentPage = request.query("page")?.toIntOrNull()?.let(::abs) ?: 1
|
||||
val tag = request.query("tag")
|
||||
val (pages, notes) = noteService.paginatedNotes(jwtPayload.userId, currentPage, tag = tag)
|
||||
return Response(OK).html(view.notes(jwtPayload, notes, currentPage, pages, tag = tag))
|
||||
val deletedCount = noteService.countDeleted(jwtPayload.userId)
|
||||
return Response(OK).html(view.notes(jwtPayload, notes, currentPage, pages, deletedCount, tag = tag))
|
||||
}
|
||||
|
||||
fun note(request: Request, jwtPayload: JwtPayload): Response {
|
||||
|
||||
@ -51,6 +51,7 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
|
||||
notes: List<PersistedNoteMetadata>,
|
||||
currentPage: Int,
|
||||
numberOfPages: Int,
|
||||
numberOfDeletedNotes: Int,
|
||||
tag: String?,
|
||||
) = renderPage(title = "Notes", jwtPayload = jwtPayload) {
|
||||
div("container mx-auto p-4") {
|
||||
@ -60,7 +61,7 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
|
||||
a(
|
||||
href = "/notes/trash",
|
||||
classes = "underline font-semibold"
|
||||
) { +"Trash" }
|
||||
) { +"Trash ($numberOfDeletedNotes)" }
|
||||
a(
|
||||
href = "/notes/new",
|
||||
classes = "ml-2 btn btn-green"
|
||||
|
||||
@ -47,6 +47,7 @@ class NoteService(
|
||||
fun trash(userId: Int, uuid: UUID) = noteRepository.delete(userId, uuid, permanent = false)
|
||||
fun restore(userId: Int, uuid: UUID) = noteRepository.restore(userId, uuid)
|
||||
fun delete(userId: Int, uuid: UUID) = noteRepository.delete(userId, uuid, permanent = true)
|
||||
fun countDeleted(userId: Int) = noteRepository.count(userId, deleted = true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user