Skip to content

Commit

Permalink
Remove useless functions and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisGuillem committed Jul 28, 2017
1 parent f9dc0f7 commit 0e40215
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 180 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ importFrom(grDevices,dev.off)
importFrom(grDevices,png)
importFrom(htmlwidgets,getDependency)
importFrom(methods,is)
importFrom(methods,new)
importFrom(methods,setRefClass)
importFrom(miniUI,gadgetTitleBar)
importFrom(miniUI,miniContentPanel)
importFrom(miniUI,miniPage)
Expand Down
79 changes: 0 additions & 79 deletions R/mwServer.R

This file was deleted.

87 changes: 0 additions & 87 deletions R/mwServer_helpers.R
Original file line number Diff line number Diff line change
@@ -1,90 +1,3 @@
#' Dynamically show/hide controls in the UI
#'
#' @param .display expression that evaluates to a named list of boolean
#' @param desc subset of controls$desc containing only shared inputs and inputs
#' for the current module
#' @param session shiny session
#' @param env module environment
#'
#' @noRd
showHideControls <- function(desc, session, env) {
displayBool <- lapply(desc$display, eval, envir = env)
for (i in seq_along(displayBool)) {
if (is.logical(displayBool[[i]])) {
shiny::updateCheckboxInput(
session,
inputId = paste0(desc$inputId[i], "_visible"),
value = displayBool[[i]]
)
}
}
}

#' Dynamically set input parameters like choices, minimal or maximal values, etc.
#'
#' @param .updateInputs expression that evaluate to a named list of lists
#' @inheritParams showHideControls
#'
#' @return data.frame 'desc' with updated column params
#' @noRd
updateControls <- function(desc, session, env) {

for (i in seq_len(nrow(desc))) {
newParams <- evalParams(desc$params[[i]], env)

args <- list(session = session, inputId = desc$inputId[i])
updateRequired <- FALSE

for (p in setdiff(names(newParams), c("value", "label"))) {
if (identical(newParams[[p]], desc$currentParams[[i]][[p]])) {
next
}

updateRequired <- TRUE
args[[p]] <- newParams[[p]]

# Special case: update value of select input when choices are modified
if (p == "choices" & desc$type[i] == "select") {
actualSelection <- get(desc$name[i], envir = env)
if (desc$multiple[[i]]) {
args$selected <- intersect(actualSelection, newParams[[p]])
} else {
if (actualSelection %in% newParams[[p]]) {
args$selected <- actualSelection
}
}
}

desc$currentParams[[i]][[p]] <- newParams[[p]]
}

if (updateRequired) {
updateInputFun <- getUpdateInputFun(desc$type[i])
do.call(updateInputFun, args)
}
}

desc
}

#' Private function that returns the function to use to update some type of inputs
#' @noRd
getUpdateInputFun <- function(type) {
switch(
type,
slider = shiny::updateSliderInput,
text = shiny::updateTextInput,
numeric = shiny::updateNumericInput,
password = shiny::updateTextInput,
select = shiny::updateSelectInput,
checkbox = shiny::updateCheckboxInput,
radio = shiny::updateRadioButtons,
date = shiny::updateDateInput,
dateRange = shiny::updateDateRangeInput,
checkboxGroup = shiny::updateCheckboxGroupInput
)
}

#' Function called when user clicks on the "Done" button. It stops the shiny
#' gadget and returns the final htmlwidget
#'
Expand Down
7 changes: 4 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ myPlotFun <- function(distribution, range, title) {
value = randomFun(n = diff(range) + 1)
)
combineWidgets(
ncol = 2, colsize = c(2, 1),
ncol = 1, rowsize = c(2, 1),
dygraph(myData, main = title),
combineWidgets(
ncol = 2,
plot_ly(x = myData$value, type = "histogram"),
paste(
"The graph on the left represents a random time series generated using a <b>",
"The graph above represents a random time series generated using a <b>",
distribution, "</b>distribution function.<br/>",
"The chart above represents the empirical distribution of the generated values."
"The chart on the left represents the empirical distribution of the generated values."
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion man/mwCheckbox.Rd

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

2 changes: 1 addition & 1 deletion man/mwCheckboxGroup.Rd

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

2 changes: 1 addition & 1 deletion man/mwDate.Rd

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

2 changes: 1 addition & 1 deletion man/mwDateRange.Rd

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

2 changes: 1 addition & 1 deletion man/mwGroup.Rd

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

2 changes: 1 addition & 1 deletion man/mwNumeric.Rd

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

2 changes: 1 addition & 1 deletion man/mwPassword.Rd

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

2 changes: 1 addition & 1 deletion man/mwRadio.Rd

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

2 changes: 1 addition & 1 deletion man/mwSelect.Rd

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

2 changes: 1 addition & 1 deletion man/mwSlider.Rd

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

2 changes: 1 addition & 1 deletion man/mwText.Rd

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

0 comments on commit 0e40215

Please sign in to comment.