Skip to content

Commit

Permalink
initial commit of bookmark script for bookmark include instead of exc…
Browse files Browse the repository at this point in the history
…lude
  • Loading branch information
alex-rogers-hub committed Dec 12, 2024
1 parent 91f1eb3 commit 7648d74
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions R/bookmark.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#' DfE bookmark include
#'
#' @description
#' This function allows for a whitelist of included inputs
#' for bookmarking
#'
#' @param bookmarkingWhitelist list of inputs to include in bookmark
#' @return a bookmark with relevant inputs included
#'
#' @export
#' @examples
#' # You will need a line such as this in your global.R script ================
#' bookmarkingWhitelist <- c("navlistPanel", "tabsetpanels")
#'
#' # In the server.R script ===================================================
#' shiny::observe({
#' setBookmarkInclude(bookmarkingWhitelist)
#' })
#'
#' observe({
#' # Trigger this observer every time an input changes
#' reactiveValuesToList(input)
#' session$doBookmark()
#' })
#'
#' onBookmarked(function(url) {
#' updateQueryString(url)
#' })
setBookmarkInclude <- function(bookmarkingWhitelist){

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.

Check notice

Code scanning / lintr

There should be a space before an opening curly brace. Note

There should be a space before an opening curly brace.

Check notice

Code scanning / lintr

There should be a space between a right parenthesis and a body expression. Note

There should be a space between a right parenthesis and a body expression.
# exclude the white list from complete list
toExclude <- setdiff(names(input), bookmarkingWhitelist)

Check notice

Code scanning / lintr

Variable and function name style should match snake_case or symbols. Note

Variable and function name style should match snake_case or symbols.

Check warning

Code scanning / lintr

no visible binding for global variable 'input' Warning

no visible binding for global variable 'input'

# print to log for testing
# print(paste("ExcludedIDs:", paste(toExclude, collapse = ", ")))

Check notice

Code scanning / lintr

Commented code should be removed. Note

Commented code should be removed.

# exclude all remaining inputs from bookmark
setBookmarkExclude(toExclude)

Check warning

Code scanning / lintr

no visible global function definition for 'setBookmarkExclude' Warning

no visible global function definition for 'setBookmarkExclude'

print('bookmarked')

Check notice

Code scanning / lintr

Only use double-quotes. Note

Only use double-quotes.
# Trigger bookmarking whenever relevant inputs change
session$doBookmark()

Check warning

Code scanning / lintr

no visible binding for global variable 'session' Warning

no visible binding for global variable 'session'
}

0 comments on commit 7648d74

Please sign in to comment.