Filter hinzugefügt
This commit is contained in:
+12
-2
@@ -1,4 +1,5 @@
|
||||
f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSelected = NULL, hoehe = NULL) {
|
||||
f_reactable <- function(daten, coldefs = NULL, selection = "single",
|
||||
defaultSelected = NULL, hoehe = NULL, highlight_valuta = NULL) {
|
||||
reactable(
|
||||
daten,
|
||||
selection = selection,
|
||||
@@ -18,7 +19,16 @@ f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSele
|
||||
# borderColor = "#dfe2e5",
|
||||
rowSelectedStyle = list(backgroundColor = "#98F5FF")#
|
||||
),
|
||||
rowStyle = list(cursor = "pointer"),
|
||||
rowStyle = function(index) {
|
||||
style <- list(cursor = "pointer") # immer aktiv
|
||||
|
||||
if (!is.null(highlight_valuta) &&
|
||||
daten$valuta[index] == highlight_valuta) {
|
||||
style$background <- "#fff3cd"
|
||||
}
|
||||
|
||||
style
|
||||
},
|
||||
onClick = "select",
|
||||
columns = coldefs
|
||||
)
|
||||
|
||||
+31
-9
@@ -19,7 +19,7 @@ buchungenUI <- function(id) {
|
||||
)
|
||||
}
|
||||
|
||||
buchungenServer <- function(id, conn) {
|
||||
buchungenServer <- function(id, conn, aktiver_filter = reactive("alle")) {
|
||||
moduleServer(id, function(input, output, session) {
|
||||
ns <- session$ns
|
||||
|
||||
@@ -30,18 +30,39 @@ buchungenServer <- function(id, conn) {
|
||||
current_main_idx <- reactiveVal(NULL)
|
||||
reset_trigger <- reactiveVal(0) # ← neu: erzwingt Re-render mit Filter-Reset
|
||||
modal_trigger <- reactiveVal(list(post_id = NULL, counter = 0))
|
||||
highlighted_valuta <- reactiveVal(NULL)
|
||||
|
||||
|
||||
update_db_trigger <- postingModuleServer("posting_modal", conn, selected_trans_id, modal_trigger)
|
||||
|
||||
gefilterte_daten <- reactive({
|
||||
d <- postings_data()
|
||||
switch(aktiver_filter(),
|
||||
"giro" = d |> filter(grepl("0130", account_name)),
|
||||
"monat" = d |> filter(
|
||||
floor_date(as.Date(valuta), "month") == floor_date(Sys.Date(), "month")
|
||||
|
||||
),
|
||||
d
|
||||
)
|
||||
})
|
||||
|
||||
observeEvent(aktiver_filter(), {
|
||||
current_main_idx(NULL)
|
||||
selected_trans_id(NULL)
|
||||
details_data(NULL)
|
||||
})
|
||||
|
||||
# * Haupttabelle rendern ----
|
||||
output$buchungen_table <- renderReactable({
|
||||
reset_trigger() # Abhängigkeit – bei Increment wird neu gerendert
|
||||
reset_trigger()
|
||||
f_reactable(
|
||||
daten = postings_data(),
|
||||
coldefs = coldef_entries_tabelle,
|
||||
selection = "single",
|
||||
hoehe = "60vh",
|
||||
defaultSelected = current_main_idx()
|
||||
daten = gefilterte_daten(), # ← geändert
|
||||
coldefs = coldef_entries_tabelle,
|
||||
selection = "single",
|
||||
hoehe = "60vh",
|
||||
defaultSelected = current_main_idx(),
|
||||
highlight_valuta = highlighted_valuta()
|
||||
)
|
||||
})
|
||||
|
||||
@@ -49,8 +70,9 @@ buchungenServer <- function(id, conn) {
|
||||
sel_details <- reactive(getReactableState("buchungen_table", "selected"))
|
||||
observeEvent(sel_details(), ignoreInit = TRUE, {
|
||||
req(sel_details())
|
||||
highlighted_valuta(gefilterte_daten()[sel_details(), "valuta"])
|
||||
current_main_idx(sel_details())
|
||||
t_id <- postings_data()[sel_details(), "entry_id"] |> pull()
|
||||
t_id <- gefilterte_daten()[sel_details(), "entry_id"] |> pull() # ← geändert
|
||||
selected_trans_id(t_id)
|
||||
details_data(read_buch_tabelle(conn, trans_id = t_id))
|
||||
})
|
||||
@@ -91,7 +113,7 @@ buchungenServer <- function(id, conn) {
|
||||
observeEvent(input$add_trans, {
|
||||
new_t_id <- max_id(conn, "entries") + 1
|
||||
dbxInsert(conn, "entries", data.frame(id = new_t_id))
|
||||
p_id1 <- max_id(conn, "postings") + 1
|
||||
p_id1 <- max_id(conn, "postings") + 1
|
||||
p_id2 <- p_id1 + 1
|
||||
dbxInsert(conn, "postings", data.frame(
|
||||
id = c(p_id1, p_id2),
|
||||
|
||||
@@ -16,7 +16,8 @@ read_buch_tabelle <- function(conn, trans_id = NULL){
|
||||
left_join(projects, by = c("project_id" = "id")) |>
|
||||
select(id, valuta, account_name, projektname, display_name, amount, entry_id) |>
|
||||
collect() %>%
|
||||
mutate(saldo = 0)
|
||||
mutate(saldo = 0) %>%
|
||||
arrange(valuta, entry_id)
|
||||
}
|
||||
|
||||
read_posting <- function(conn, id){
|
||||
|
||||
Reference in New Issue
Block a user