From 8a3527b487b4021969c25e5a5b358d8705ab3abd Mon Sep 17 00:00:00 2001 From: Eric Nantz Date: Sun, 17 Mar 2024 20:46:38 +0000 Subject: [PATCH] add webassembly app prototyping files --- app/R/fct_tables.R | 7 +++++++ app/R/mod_tbl.R | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 app/R/fct_tables.R create mode 100644 app/R/mod_tbl.R diff --git a/app/R/fct_tables.R b/app/R/fct_tables.R new file mode 100644 index 0000000..2bc9068 --- /dev/null +++ b/app/R/fct_tables.R @@ -0,0 +1,7 @@ +record_analysis_table <- function(df) { + reactable::reactable(df) +} + +record_detail_table <- function(df) { + reactable::reactable(df) +} \ No newline at end of file diff --git a/app/R/mod_tbl.R b/app/R/mod_tbl.R new file mode 100644 index 0000000..01f0d5d --- /dev/null +++ b/app/R/mod_tbl.R @@ -0,0 +1,36 @@ +#' tbl UI Function +#' +#' @description A shiny Module. +#' +#' @param id,input,output,session Internal parameters for {shiny}. +#' +#' @noRd +#' +#' @importFrom shiny NS tagList +mod_tbl_ui <- function(id) { + ns <- NS(id) + tagList( + reactable::reactableOutput(ns("record_table")) + ) +} + +#' tbl Server Functions +#' +#' @noRd +#' +mod_tbl_server <- function(id, record_df) { + moduleServer(id, function(input, output, session) { + ns <- session$ns + + output$record_table <- reactable::renderReactable({ + req(record_df()) + record_detail_table(record_df()) + }) + }) +} + +## To be copied in the UI +# mod_tbl_ui("tbl_1") + +## To be copied in the server +# mod_tbl_server("tbl_1") \ No newline at end of file