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

Misc plot fixes #285

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ S3method(generate_code,arrange_block)
S3method(generate_code,block)
S3method(generate_code,call)
S3method(generate_code,data_block)
S3method(generate_code,plot_block)
S3method(generate_code,stack)
S3method(generate_code,transform_block)
S3method(generate_server,data_block)
Expand Down
19 changes: 18 additions & 1 deletion R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
NextMethod()
}

#' @rdname new_block
#' @export
generate_code.plot_block <- function(x) {

if (!is_initialized(x)) {
return(quote(identity()))

Check warning on line 130 in R/block.R

View check run for this annotation

Codecov / codecov/patch

R/block.R#L129-L130

Added lines #L129 - L130 were not covered by tests
}

NextMethod()

Check warning on line 133 in R/block.R

View check run for this annotation

Codecov / codecov/patch

R/block.R#L133

Added line #L133 was not covered by tests
}

#' @rdname new_block
#' @export
generate_code.call <- function(x) {
Expand Down Expand Up @@ -155,7 +166,13 @@
#' @param data Result from previous block
#' @rdname new_block
#' @export
evaluate_block.plot_block <- evaluate_block.transform_block
evaluate_block.plot_block <- function(x, data, ...) {
stopifnot(...length() == 0L)
eval(
substitute(data %>% expr, list(expr = generate_code(x))),
list(data = data)

Check warning on line 173 in R/block.R

View check run for this annotation

Codecov / codecov/patch

R/block.R#L170-L173

Added lines #L170 - L173 were not covered by tests
)
}

#' @param data Result from previous block
#' @rdname new_block
Expand Down
4 changes: 4 additions & 0 deletions R/field.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ update_field.field <- function(x, new, env = list()) {

x <- eval_set_field_value(x, env)

if (!length(new)) {
return(validate_field(x))
}

value(x) <- new

res <- validate_field(x)
Expand Down
17 changes: 12 additions & 5 deletions R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,19 @@ ui_input.string_field <- function(x, id, name) {
#' @rdname generate_ui
#' @export
ui_input.select_field <- function(x, id, name) {

opts <- list(
dropdownParent = "body",
placeholder = "Please select an option below"
)

if (!isTRUE(value(x, "multiple"))) {
opts <- c(opts, list(maxItems = 1L))
}

selectizeInput(
input_ids(x, id), name, value(x, "choices"), value(x), value(x, "multiple"),
options = list(
dropdownParent = "body",
placeholder = "Please select an option below"
)
input_ids(x, id), name, value(x, "choices"), value(x), multiple = TRUE,
options = opts
)
}

Expand Down
3 changes: 3 additions & 0 deletions man/new_block.Rd

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

Loading