Buchungs modal um actions erweitert
This commit is contained in:
+21
-9
@@ -3,7 +3,10 @@ buchungenUI <- function(id) {
|
||||
tagList(
|
||||
reactableOutput(ns("buchungen_table")),
|
||||
reactableOutput(ns("details_table")),
|
||||
postingModuleUI(ns("posting_modal"))
|
||||
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")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,7 +16,8 @@ buchungenServer <- function(id) {
|
||||
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)
|
||||
|
||||
@@ -25,24 +29,32 @@ buchungenServer <- function(id) {
|
||||
f_reactable(postings(), coldefs = coldef_entries_tabelle)
|
||||
})
|
||||
|
||||
# Modal zum editieren
|
||||
# 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)
|
||||
details(read_buch_tabelle(conn, trans_id = idwert))
|
||||
output$details_table <- renderReactable(
|
||||
f_reactable(details, coldefs = coldef_entries_tabelle)
|
||||
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
|
||||
postingModuleServer("posting_modal",conn, idwert)
|
||||
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))
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user