tabelle ohne paginierung, trans-aktionen korrigiert
This commit is contained in:
+27
-8
@@ -27,6 +27,8 @@ buchungenServer <- function(id, conn) {
|
||||
details_data <- reactiveVal(NULL)
|
||||
selected_trans_id <- reactiveVal(NULL)
|
||||
current_main_idx <- reactiveVal(NULL)
|
||||
current_page <- reactiveVal(1)
|
||||
|
||||
|
||||
# Trigger-Objekt für das Modal: enthält post_id und einen Counter
|
||||
# Der Counter erzwingt eine Reaktion, auch wenn die gleiche ID zweimal geklickt wird
|
||||
@@ -40,9 +42,12 @@ buchungenServer <- function(id, conn) {
|
||||
req(postings_data())
|
||||
f_reactable(daten = postings_data(), coldefs = coldef_entries_tabelle,
|
||||
selection = "single",
|
||||
hoehe = "60vh",
|
||||
defaultSelected = current_main_idx())
|
||||
})
|
||||
|
||||
|
||||
|
||||
# Details laden wenn Zeile gewählt wird ----
|
||||
sel_details <- reactive(getReactableState("buchungen_table", "selected"))
|
||||
observeEvent(sel_details(), ignoreInit = T, {
|
||||
@@ -54,7 +59,7 @@ buchungenServer <- function(id, conn) {
|
||||
|
||||
output$details_table <- renderReactable({
|
||||
req(details_data())
|
||||
f_reactable(details_data(), coldefs = coldef_entries_tabelle, selection = "single")
|
||||
f_reactable(details_data(), coldefs = coldef_entries_tabelle, selection = "single", hoehe = NULL)
|
||||
})
|
||||
|
||||
# Event: Detail hinzufügen (Neu) ----
|
||||
@@ -78,33 +83,47 @@ buchungenServer <- function(id, conn) {
|
||||
details_data(read_buch_tabelle(conn, trans_id = selected_trans_id()))
|
||||
# Optional: Auch Haupttabelle erneuern, falls sich Summen geändert haben
|
||||
postings_data(read_buch_tabelle(conn))
|
||||
updateReactable("buchungen_table", data = postings_data(read_buch_tabelle(conn)))
|
||||
})
|
||||
|
||||
# 'Neue Transaktion' Observer ----
|
||||
# Neue Transaktion Observer ----
|
||||
observeEvent(input$add_trans, {
|
||||
new_t_id <- max_id(conn, "entries") + 1
|
||||
|
||||
# 1. Entry anlegen
|
||||
# 1. Entry anlegen
|
||||
dbxInsert(conn, "entries", data.frame(id = new_t_id))
|
||||
|
||||
# 2. Zwei Postings direkt vor-anlegen (z.B. mit Betrag 0)
|
||||
p_id1 <- max_id(conn, "postings") + 1
|
||||
p_id2 <- p_id1 + 1
|
||||
|
||||
new_postings <- data.frame(
|
||||
id = c(p_id1, p_id2),
|
||||
entry_id = c(new_t_id, new_t_id),
|
||||
amount = c(0, 0),
|
||||
account_id = c(0, 0),
|
||||
valuta = c(Sys.Date(), Sys.Date())
|
||||
|
||||
)
|
||||
dbxInsert(conn, "postings", new_postings)
|
||||
|
||||
# 3. UI refreshen
|
||||
selected_trans_id(new_t_id)
|
||||
postings_data(read_buch_tabelle(conn))
|
||||
details_data(read_buch_tabelle(conn, trans_id = new_t_id))
|
||||
daten_postings <- postings_data()
|
||||
daten_details <- details_data()
|
||||
|
||||
updateReactable("buchungen_table", data = daten_postings)
|
||||
})
|
||||
|
||||
observeEvent(input$del_trans, ignoreInit = T, {
|
||||
req(selected_trans_id())
|
||||
print( selected_trans_id())
|
||||
dbxDelete(conn, "postings", where = data.frame(entry_id= selected_trans_id()))
|
||||
dbxDelete(conn, "entries", where = data.frame(id = selected_trans_id()))
|
||||
postings_data(read_buch_tabelle(conn))
|
||||
details_data(leer_df_from_table(conn, "postings") )
|
||||
daten_postings <- postings_data()
|
||||
daten_details <- details_data()
|
||||
updateReactable("buchungen_table", data = daten_postings)
|
||||
updateReactable("details_table", data = daten_details )
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user