60 lines
2.2 KiB
R
60 lines
2.2 KiB
R
buchungenUI <- function(id) {
|
|
ns <- NS(id)
|
|
tagList(
|
|
reactableOutput(ns("buchungen_table")),
|
|
reactableOutput(ns("details_table")),
|
|
postingModuleUI(ns("posting_modal")),
|
|
actionBttn(ns("add_trans"), "Transaktion hinzu", size = "sm", style = "material-flat", color = "warning"),
|
|
actionBttn(ns("add_trans"), "Transaktion Löschen", size = "sm", style = "material-flat", color = "danger"),
|
|
actionBttn(ns("add_detail"), "Detail hinzu", size = "sm", style = "material-flat", color = "success")
|
|
)
|
|
}
|
|
|
|
|
|
buchungenServer <- function(id) {
|
|
moduleServer(id, function(input, output, session) {
|
|
ns <- session$ns
|
|
|
|
postings <- reactiveVal(read_buch_tabelle(conn))
|
|
details <- reactiveVal()
|
|
tabelle_neu <- reactiveVal()
|
|
# NEU: Eine reactive variable für die ID, die wir editieren wollen
|
|
# current_entry_id <- reactiveVal(NULL)
|
|
|
|
# NEU: Den Modul-Server EINMALIG hier oben starten (nicht im Observer!)
|
|
# entryEditServer("entry_edit", entry_id = current_entry_id, conn = conn)
|
|
|
|
output$buchungen_table <- renderReactable({
|
|
# req(postings())
|
|
f_reactable(postings(), coldefs = coldef_entries_tabelle)
|
|
})
|
|
|
|
# Buchungen und gegenbuchungen anzeigen
|
|
selected <- reactive(getReactableState("buchungen_table", "selected"))
|
|
observeEvent(selected(), {
|
|
idwert <- postings()[selected(),"entry_id"] %>% pull
|
|
details(read_buch_tabelle(conn, trans_id = idwert))
|
|
output$details_table <- renderReactable(
|
|
f_reactable(details(), coldefs = coldef_entries_tabelle)
|
|
)
|
|
})
|
|
|
|
# Buchunge auswähle
|
|
selected_det <- reactive(getReactableState("details_table", "selected"))
|
|
observeEvent(selected_det(),{
|
|
idwert <- postings()[selected(),"id"] %>% pull
|
|
tabelle_neu(postingModuleServer("posting_modal",conn, idwert))
|
|
})
|
|
# Buchungstail hinzufügen
|
|
observeEvent(input$add_detail, ignoreInit = T, {
|
|
trans_id <- idwert <- postings()[selected(),"entry_id"] %>% pull
|
|
post_id <- max_id(conn, "posting") + 1
|
|
tabelle_neu(postingModuleServer("posting_modal",conn, idwert, post_id + 1))
|
|
})
|
|
# Tabelle aktualisieren
|
|
observeEvent(tabelle_neu(), ignoreInit = T, {
|
|
details(read_buch_tabelle(conn, trans_id = idwert))
|
|
})
|
|
|
|
})
|
|
} |