tabelle ohne paginierung, trans-aktionen korrigiert
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSelected = NULL) {
|
f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSelected = NULL, hoehe = NULL) {
|
||||||
reactable(
|
reactable(
|
||||||
daten,
|
daten,
|
||||||
selection = selection,
|
selection = selection,
|
||||||
defaultSelected = defaultSelected, # Ermöglicht das Wiederherstellen der Auswahl
|
defaultSelected = defaultSelected, # Ermöglicht das Wiederherstellen der Auswahl
|
||||||
pagination = TRUE,
|
pagination = F,
|
||||||
defaultPageSize = 17,
|
defaultPageSize = 17,
|
||||||
showPageSizeOptions = TRUE,
|
showPageSizeOptions = TRUE,
|
||||||
filterable = TRUE,
|
filterable = TRUE,
|
||||||
highlight = TRUE,
|
highlight = TRUE,
|
||||||
|
height = hoehe, # <--- FIXIERT DEN HEADER und macht den Body scrollbar
|
||||||
bordered = TRUE,
|
bordered = TRUE,
|
||||||
striped = FALSE,
|
striped = FALSE,
|
||||||
compact = TRUE,
|
compact = TRUE,
|
||||||
|
|||||||
+26
-7
@@ -27,6 +27,8 @@ buchungenServer <- function(id, conn) {
|
|||||||
details_data <- reactiveVal(NULL)
|
details_data <- reactiveVal(NULL)
|
||||||
selected_trans_id <- reactiveVal(NULL)
|
selected_trans_id <- reactiveVal(NULL)
|
||||||
current_main_idx <- reactiveVal(NULL)
|
current_main_idx <- reactiveVal(NULL)
|
||||||
|
current_page <- reactiveVal(1)
|
||||||
|
|
||||||
|
|
||||||
# Trigger-Objekt für das Modal: enthält post_id und einen Counter
|
# 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
|
# Der Counter erzwingt eine Reaktion, auch wenn die gleiche ID zweimal geklickt wird
|
||||||
@@ -40,9 +42,12 @@ buchungenServer <- function(id, conn) {
|
|||||||
req(postings_data())
|
req(postings_data())
|
||||||
f_reactable(daten = postings_data(), coldefs = coldef_entries_tabelle,
|
f_reactable(daten = postings_data(), coldefs = coldef_entries_tabelle,
|
||||||
selection = "single",
|
selection = "single",
|
||||||
|
hoehe = "60vh",
|
||||||
defaultSelected = current_main_idx())
|
defaultSelected = current_main_idx())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Details laden wenn Zeile gewählt wird ----
|
# Details laden wenn Zeile gewählt wird ----
|
||||||
sel_details <- reactive(getReactableState("buchungen_table", "selected"))
|
sel_details <- reactive(getReactableState("buchungen_table", "selected"))
|
||||||
observeEvent(sel_details(), ignoreInit = T, {
|
observeEvent(sel_details(), ignoreInit = T, {
|
||||||
@@ -54,7 +59,7 @@ buchungenServer <- function(id, conn) {
|
|||||||
|
|
||||||
output$details_table <- renderReactable({
|
output$details_table <- renderReactable({
|
||||||
req(details_data())
|
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) ----
|
# Event: Detail hinzufügen (Neu) ----
|
||||||
@@ -78,33 +83,47 @@ buchungenServer <- function(id, conn) {
|
|||||||
details_data(read_buch_tabelle(conn, trans_id = selected_trans_id()))
|
details_data(read_buch_tabelle(conn, trans_id = selected_trans_id()))
|
||||||
# Optional: Auch Haupttabelle erneuern, falls sich Summen geändert haben
|
# Optional: Auch Haupttabelle erneuern, falls sich Summen geändert haben
|
||||||
postings_data(read_buch_tabelle(conn))
|
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, {
|
observeEvent(input$add_trans, {
|
||||||
new_t_id <- max_id(conn, "entries") + 1
|
new_t_id <- max_id(conn, "entries") + 1
|
||||||
|
|
||||||
# 1. Entry anlegen
|
# 1. Entry anlegen
|
||||||
dbxInsert(conn, "entries", data.frame(id = new_t_id))
|
dbxInsert(conn, "entries", data.frame(id = new_t_id))
|
||||||
|
|
||||||
# 2. Zwei Postings direkt vor-anlegen (z.B. mit Betrag 0)
|
# 2. Zwei Postings direkt vor-anlegen (z.B. mit Betrag 0)
|
||||||
p_id1 <- max_id(conn, "postings") + 1
|
p_id1 <- max_id(conn, "postings") + 1
|
||||||
p_id2 <- p_id1 + 1
|
p_id2 <- p_id1 + 1
|
||||||
|
|
||||||
new_postings <- data.frame(
|
new_postings <- data.frame(
|
||||||
id = c(p_id1, p_id2),
|
id = c(p_id1, p_id2),
|
||||||
entry_id = c(new_t_id, new_t_id),
|
entry_id = c(new_t_id, new_t_id),
|
||||||
amount = c(0, 0),
|
amount = c(0, 0),
|
||||||
account_id = c(0, 0),
|
account_id = c(0, 0),
|
||||||
valuta = c(Sys.Date(), Sys.Date())
|
valuta = c(Sys.Date(), Sys.Date())
|
||||||
|
|
||||||
)
|
)
|
||||||
dbxInsert(conn, "postings", new_postings)
|
dbxInsert(conn, "postings", new_postings)
|
||||||
|
|
||||||
# 3. UI refreshen
|
# 3. UI refreshen
|
||||||
selected_trans_id(new_t_id)
|
selected_trans_id(new_t_id)
|
||||||
postings_data(read_buch_tabelle(conn))
|
postings_data(read_buch_tabelle(conn))
|
||||||
details_data(read_buch_tabelle(conn, trans_id = new_t_id))
|
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 )
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user