Attachments Liste wird jetzt angezeigt und attachment in iframe

This commit is contained in:
2026-03-20 17:32:13 +01:00
parent 581c6d9ecc
commit 71621ad8ac
3 changed files with 45 additions and 12 deletions
+1
View File
@@ -3,4 +3,5 @@
.Rhistory .Rhistory
.RData .RData
.Ruserdata .Ruserdata
www/attachments/
+15 -2
View File
@@ -153,7 +153,6 @@ buchungenServer <- function(id, conn, aktiver_filter = reactive("alle")) {
}) })
## * Attachments anzeigen ----
output$attachments_ui <- renderUI({ output$attachments_ui <- renderUI({
req(selected_trans_id()) req(selected_trans_id())
att <- dbxSelect(conn, paste0( att <- dbxSelect(conn, paste0(
@@ -162,8 +161,22 @@ buchungenServer <- function(id, conn, aktiver_filter = reactive("alle")) {
if (nrow(att) == 0) return(p("Keine Anhänge vorhanden.")) if (nrow(att) == 0) return(p("Keine Anhänge vorhanden."))
tagList(lapply(seq_len(nrow(att)), function(i) { tagList(lapply(seq_len(nrow(att)), function(i) {
ext <- tools::file_ext(att$original_name[i])
filename <- paste0("attachments/", att$id[i], ".", ext)
# Observer direkt hier registrieren
observeEvent(input[[paste0("open_att_", att$id[i])]], {
showModal(modalDialog(
tags$iframe(src = filename, width = "100%", height = "600px", style = "border:none;"),
title = att$original_name[i],
size = "l",
easyClose = TRUE,
footer = modalButton("Schließen")
))
}, ignoreInit = TRUE, once = FALSE)
div( div(
tags$a(att$original_name[i], href = att$path[i], target = "_blank"), actionLink(ns(paste0("open_att_", att$id[i])), att$original_name[i]),
actionLink(ns(paste0("del_att_", att$id[i])), "✕", actionLink(ns(paste0("del_att_", att$id[i])), "✕",
style = "color:red; margin-left:8px;") style = "color:red; margin-left:8px;")
) )
+22 -3
View File
@@ -9,14 +9,25 @@ read_buch_tabelle <- function(conn, trans_id = NULL){
accounts <- tbl(conn, "accounts") accounts <- tbl(conn, "accounts")
projects <- tbl(conn, "projects") projects <- tbl(conn, "projects")
contacts <- tbl(conn, "contacts") contacts <- tbl(conn, "contacts")
attachments <- tbl(conn, "attachments")
# Anzahl Attachments pro entry_id vorberechnen
attachment_counts <- attachments %>%
group_by(entry_id) %>%
summarise(n_attachments = n(), .groups = "drop")
result <- postings |> result <- postings |>
left_join(entries, by = c("entry_id" = "id")) |> left_join(entries, by = c("entry_id" = "id")) |>
left_join(contacts, by = c("contact_id" = "id")) |> # contact_id jetzt verfügbar left_join(contacts, by = c("contact_id" = "id")) |>
left_join(accounts, by = c("account_id" = "id")) |> left_join(accounts, by = c("account_id" = "id")) |>
left_join(projects, by = c("project_id" = "id")) |> left_join(projects, by = c("project_id" = "id")) |>
select(id, valuta, account_name, projektname, display_name, amount, entry_id) |> left_join(attachment_counts, by = "entry_id") |>
select(id, valuta, account_name, projektname, display_name, amount, entry_id, n_attachments) |>
collect() %>% collect() %>%
mutate(saldo = 0) %>% mutate(
saldo = 0,
n_attachments = tidyr::replace_na(n_attachments, 0L)
) %>%
arrange(valuta, entry_id) arrange(valuta, entry_id)
} }
@@ -39,6 +50,14 @@ coldef_entries_tabelle <-
list(color = color, fontWeight = "bold") # Gibt CSS-Styles zurück list(color = color, fontWeight = "bold") # Gibt CSS-Styles zurück
} }
), ),
n_attachments = colDef(
name = "Anhänge",
filterMethod = JS("function(rows, columnId, filterValue) {
const val = parseFloat(filterValue);
if (isNaN(val)) return rows; // kein gültiger Wert → alles zeigen
return rows.filter(row => row.values[columnId] > val);
}")
),
entry_id = colDef(name ="trans_id", width = 120), entry_id = colDef(name ="trans_id", width = 120),
saldo = colDef( saldo = colDef(
name = "Saldo", name = "Saldo",