R/button_bar.R

Defines functions server_button_bar ui_button_bar

#' @importFrom purrr map exec
ui_button_bar <- function(ns, buttons) {
  exec(div, id = ns("button_bar"), class = "ag-button-bar",
       !!!unname(map(buttons, ~ .x$ui(ns))))
}

#' @importFrom purrr exec walk
server_button_bar <- function(ns, buttons, input, output, ...) {
  args <- list(...)
  any_row_selected <- reactive(!is.null(input[["table_rows_selected"]]))
  
  walk(buttons, ~ exec(.x$server, input, output, !!!args))
  walk(
    BUTTON_TAGS[collect_tags(buttons)],
    ~ .x(ns, ..., any_row_selected = any_row_selected)
  )
}
KotulskaLab/AmyloGraph documentation built on June 30, 2023, 8:48 p.m.