Buchungen-popup funktioniert
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
# entry_edit_mod.R
|
||||
entryEditUI <- function(id) {
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
|
||||
uiOutput(ns("entry_ui")),
|
||||
uiOutput(ns("postings_ui"))
|
||||
)
|
||||
}
|
||||
|
||||
entryEditServer <- function(id, entry_id, conn) {
|
||||
moduleServer(id, function(input, output, session) {
|
||||
ns <- session$ns
|
||||
|
||||
entry_postings <- reactiveVal(read_postings_by_entry(conn, entry_id))
|
||||
entry_data <- reactiveVal(read_entry(conn, entry_id))
|
||||
|
||||
output$entry_ui <- renderUI({
|
||||
e <- entry_data()
|
||||
tagList(
|
||||
fluidRow(
|
||||
column(6, selectizeInput(ns("contact_id"), "Kontakt",
|
||||
choices = get_contact_choices(conn),
|
||||
selected = e$contact_id)),
|
||||
column(6, textInput(ns("purpose"), "Verwendungszweck", value = e$purpose))
|
||||
),
|
||||
hr()
|
||||
)
|
||||
})
|
||||
|
||||
# Choices für contact nach dem Flush setzen
|
||||
|
||||
|
||||
output$postings_ui <- renderUI({
|
||||
alle <- entry_postings()
|
||||
lapply(seq_len(nrow(alle)), function(i) {
|
||||
print(paste("project selected:", alle$project_id[i]))
|
||||
print(head(get_project_choices(conn)))
|
||||
print(class(get_project_choices(conn)))
|
||||
div(
|
||||
style = "border-left: 3px solid #3c8dbc; padding: 5px; margin-bottom: 5px",
|
||||
fluidRow(
|
||||
column(3,
|
||||
selectInput(ns(paste0("account_id_", i)), "Konto",
|
||||
choices = get_account_choices(conn),
|
||||
selected = as.character(alle$account_id[i]))
|
||||
),
|
||||
column(3, selectizeInput(ns(paste0("project_id_", i)), "Projekt",
|
||||
choices = get_project_choices(conn),
|
||||
selected = ifelse(is.na(alle$project_id[i]), "", as.character(alle$project_id[i])))
|
||||
),
|
||||
column(2, numericInput(ns(paste0("amount_", i)), "Betrag", value = alle$amount[i])),
|
||||
column(3, textInput(ns(paste0("notiz_", i)), "Notiz", value = alle$notiz[i])),
|
||||
column(1, actionButton(ns(paste0("delete_", i)), "", icon = icon("trash"), class = "btn-danger btn-sm"))
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
# Choices befüllen nachdem renderUI fertig ist
|
||||
observe({
|
||||
alle <- entry_postings()
|
||||
e <- entry_data()
|
||||
req(nrow(alle) > 0, nrow(e) > 0)
|
||||
|
||||
session$onFlushed(function() {
|
||||
# Contact
|
||||
updateSelectizeInput(session, "contact_id",
|
||||
choices = get_contact_choices(conn),
|
||||
selected = e$contact_id)
|
||||
|
||||
# Postings
|
||||
lapply(seq_len(nrow(alle)), function(i) {
|
||||
updateSelectizeInput(session, paste0("account_id_", i),
|
||||
choices = get_account_choices(conn),
|
||||
selected = alle$account_id[i])
|
||||
updateSelectizeInput(session, paste0("project_id_", i),
|
||||
choices = get_project_choices(conn),
|
||||
selected = alle$project_id[i])
|
||||
})
|
||||
}, once = TRUE)
|
||||
})
|
||||
|
||||
# Speichern-Logik
|
||||
observeEvent(input$speichern, {
|
||||
alle <- entry_postings()
|
||||
lapply(seq_len(nrow(alle)), function(i) {
|
||||
# update posting i in DB
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user