Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge main into new page design #95

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ Imports:
usethis,
utils,
yaml
URL: https://github.com/surveydown-dev/surveydown
url: https://pkg.surveydown.org/
BugReports: https://github.com/surveydown-dev/surveydown/issues
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# surveydown (development version)


- Modified `sd_get_url_pars()` to include `reactive()` with the `()` at the end, so now the function returns an evaluated reactive expression.

# surveydown 0.2.4

Expand Down
31 changes: 18 additions & 13 deletions R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -519,24 +519,29 @@ countdown_js <- function(delay, redirect_js, countdown_id, unique_id) {
#' @examples
#' # Examples here
sd_get_url_pars <- function(...) {
session <- shiny::getDefaultReactiveDomain()
shiny::reactive({
session <- shiny::getDefaultReactiveDomain()

if (is.null(session)) {
stop("sd_get_url_pars() must be called from within a Shiny reactive context")
}
if (is.null(session)) {
stop("sd_get_url_pars() must be called from within a Shiny reactive context")
}

full_url <- session$clientData$url_search
parsed_query <- shiny::parseQueryString(full_url)
full_url <- session$clientData$url_search
parsed_query <- shiny::parseQueryString(full_url)

requested_params <- list(...)
requested_params <- list(...)

if (length(requested_params) == 0) {
return(parsed_query)
}
if (length(requested_params) == 0) {
return(parsed_query)
}

requested_params <- unlist(requested_params)
filtered_query <- parsed_query[requested_params]
filtered_query[!sapply(filtered_query, is.null)]
})()
# Extra parentheses is added so that the reactive expression is evaluated
# when the function is called

requested_params <- unlist(requested_params)
filtered_query <- parsed_query[requested_params]
filtered_query[!sapply(filtered_query, is.null)]
}

#' Create a placeholder for a reactive survey question
Expand Down
5 changes: 3 additions & 2 deletions R/version.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#'
#' @param force Logical; if TRUE, forces an update regardless of current versions.
#' Defaults to FALSE.
#' @param ... Optional arguments to pass on to `sd_update_extension()`
#'
#' @return No return value, called for side effects.
#' @export
Expand All @@ -15,7 +16,7 @@
#' sd_update_surveydown()
#' sd_update_surveydown(force = TRUE)
#' }
sd_update_surveydown <- function(force = FALSE) {
sd_update_surveydown <- function(force = FALSE, ...) {
# Check R package version
pkg_version <- utils::packageVersion("surveydown")

Expand All @@ -40,7 +41,7 @@ sd_update_surveydown <- function(force = FALSE) {
)

message("Updating surveydown Quarto extension...")
surveydown::sd_update_extension()
surveydown::sd_update_extension(...)

message("Update complete.")
} else {
Expand Down
44 changes: 44 additions & 0 deletions inst/template/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# remotes::install_github("surveydown-dev/surveydown", force = TRUE)
library(surveydown)

# Database setup

# surveydown stores data on a database that you define at https://supabase.com/
# To connect to a database, update the sd_database() function with details
# from your supabase database. For this demo, we set ignore = TRUE, which will
# ignore the settings and won't attempt to connect to the database. This is
# helpful for local testing if you don't want to record testing data in the
# database table. See the documentation for details:
# https://surveydown.org/store-data

db <- sd_database(
host = "",
dbname = "",
port = "",
user = "",
table = "",
ignore = TRUE
)

# UI setup
ui <- sd_ui()

# Server setup
server <- function(input, output, session) {

# Config setup
config <- sd_config()

# sd_server() initiates your survey - don't change it
sd_server(
input = input,
output = output,
session = session,
config = config,
db = db
)

}

# shinyApp() initiates your app - don't change it
shiny::shinyApp(ui = ui, server = server)
44 changes: 22 additions & 22 deletions surveydown.Rproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Loading