Skip to content

Commit

Permalink
move observeEvent out of for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Krajcik committed Jan 17, 2024
1 parent a92d9b5 commit 7639d29
Showing 1 changed file with 50 additions and 35 deletions.
85 changes: 50 additions & 35 deletions R/mod_uploadPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ uploadPackageUI <- function(id) {
column(
width = 8,
div(id = "chk-dependencies-grp",
shinyjs::hidden(
shinyWidgets::awesomeCheckbox(
inputId = NS(id, "assess_deps"),
label = "Assess Dependencies",
status = "danger",
value = FALSE
)
))
)
),
uiOutput(NS(id, "rem_pkg_div"))
),
Expand Down Expand Up @@ -226,8 +225,6 @@ uploadPackageServer <- function(id, user, auto_list, credentials, parent) {
uploaded_pkgs00(uploaded_packages)
})



observeEvent(input$add_pkgs, {
req(input$pkg_lst)

Expand Down Expand Up @@ -319,6 +316,44 @@ uploadPackageServer <- function(id, user, auto_list, credentials, parent) {
))
})

dependencies <- reactiveValues(pkg = NULL, tbl = NULL)

observeEvent(dependencies$tbl, {
req(dependencies$tbl)

DT::dataTableOutput(NS(id, "dependencies$tbl"))

showModal(modalDialog(
size = "l",
easyClose = TRUE,
footer = list(
actionButton(ns("confirmTbl"), "OK"),
modalButton("Dismss")),
strong(glue::glue("Dependencies for package: ",dependencies$pkg, style = 'text-align: left'),
hr(),
br(),
fluidRow(
column(
width = 12,
output$depends_tbl <- DT::renderDataTable(
DT::datatable(
dependencies$tbl,
escape = FALSE,
editable = FALSE,
filter = 'none',
selection = 'none',
extensions = 'Buttons',
options = list(
aLengthMenu = list(c(15, 25, -1), list('10', '25', 'All')),
pageLength = 15,
dom = "ltp"
)
))
))
)))

}, ignoreInit = TRUE)

uploaded_pkgs <- reactiveVal(data.frame())
# Save all the uploaded packages, marking them as 'new', 'not found',
# 'duplicate' or 'removed'
Expand Down Expand Up @@ -413,39 +448,19 @@ uploadPackageServer <- function(id, user, auto_list, credentials, parent) {
pkg_df$score[j] <- round(as.numeric(metric_row$pkg_score), 2)
}
}
print(pkg_df) # diagnostic

deps_tbl <- pkg_df[,3:5]

DT::dataTableOutput(NS(id, "deps_tbl"))
dependencies$pkg <- uploaded_packages$package[i]
dependencies$tbl <- pkg_df[,3:5]

showModal(modalDialog(
size = "l",
easyClose = TRUE,
footer = modalButton("Dismss"),
strong(glue::glue("Dependencies for package: ",uploaded_packages$package[i]), style = 'text-align: left'),
hr(),
br(),
fluidRow(
column(
width = 12,
output$deps_tbl <- DT::renderDataTable(
DT::datatable(
deps_tbl,
escape = FALSE,
editable = FALSE,
filter = 'none',
selection = 'none',
extensions = 'Buttons',
options = list(
sScrollX = "100%",
aLengthMenu = list(c(15, 25, -1), list('10', '25', 'All')),
iDisplayLength = 15,
dom = 't'
)
))
))
))
observeEvent(input$confirmTbl, {
req(input$confirmTbl)
cat("response from modal:", input$confirmTbl, "\n")
shiny::removeModal()
}, ignoreInit = TRUE)

# req(input$confirmTbl == 1L)

cat("got past the req() \n")

}

Expand Down

0 comments on commit 7639d29

Please sign in to comment.