Skip to content

Commit

Permalink
added file_extensions arg to import_modal()
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 1, 2022
1 parent 162f4d8 commit bf51429
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
15 changes: 11 additions & 4 deletions R/import-modal.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param id Module's id
#' @param from The import_ui & server to use, i.e. the method.
#' There are 5 options to choose from. ("env", "file", "copypaste", "googlesheets", "url")
#' @inheritParams import-file
#'
#' @template module-import
#'
Expand All @@ -18,7 +19,9 @@
#'
#' @example examples/modal.R
#'
import_ui <- function(id, from = c("env", "file", "copypaste", "googlesheets", "url")) {
import_ui <- function(id,
from = c("env", "file", "copypaste", "googlesheets", "url"),
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".rds", ".fst", ".sas7bdat", ".sav")) {
ns <- NS(id)
from <- match.arg(from, several.ok = TRUE)

Expand All @@ -34,7 +37,7 @@ import_ui <- function(id, from = c("env", "file", "copypaste", "googlesheets", "
tabPanelBody(
value = "file",
tags$br(),
import_file_ui(id = ns("file"), title = NULL)
import_file_ui(id = ns("file"), title = NULL, file_extensions = file_extensions)
)
}

Expand Down Expand Up @@ -392,7 +395,11 @@ import_server <- function(id,
#' @rdname import-modal
#' @importFrom shiny modalDialog showModal
#' @importFrom htmltools tags css
import_modal <- function(id, from, title = "Import data", size = "l") {
import_modal <- function(id,
from,
title = "Import data",
size = "l",
file_extensions = c(".csv", ".txt", ".xls", ".xlsx", ".rds", ".fst", ".sas7bdat", ".sav")) {
showModal(modalDialog(
title = tagList(
tags$button(
Expand All @@ -405,7 +412,7 @@ import_modal <- function(id, from, title = "Import data", size = "l") {
),
title
),
import_ui(id, from),
import_ui(id, from, file_extensions = file_extensions),
size = size,
footer = NULL
))
Expand Down
18 changes: 16 additions & 2 deletions man/import-modal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf51429

Please sign in to comment.