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

Fixing Duplicated Date Input Icon #410

Closed
wants to merge 1 commit 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
32 changes: 9 additions & 23 deletions R/date_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#' @param min Minimum date that can be selected.
#' @param max Maximum date that can be selected.
#' @param style Css style for widget.
#' @param icon_name Icon that should be displayed on widget.
#'
#' @examples
#' if (interactive()) {
Expand Down Expand Up @@ -44,42 +43,29 @@
#'
#' @export
#' @rdname date_input
date_input <- function(input_id, label = NULL, value = NULL, min = NULL, max = NULL,
style = NULL, icon_name = "calendar") {
class <- paste(input_id, "ui input")
if (!is.null(icon))
class <- paste(class, "icon")
date_input <- function(input_id, label = NULL, value = NULL, min = NULL, max = NULL, style = NULL) {
if (is.null(min)) min <- NA
if (is.null(max)) max <- NA

shiny::tagList(
shiny::div(class = class,
style = style,
label,
shiny.semantic::shiny_text_input(
input_id,
shiny::tags$input(type = "date", name = input_id, min = min, max = max),
value = value),
icon(icon_name))
shiny::div(
class = paste(input_id, "ui input"),
style = style,
tags$label(label),
calendar(input_id, value, min = min, max = max)
)
}

#' @param inputId Input id.
#' @param label Label to be displayed with date input.
#' @param value Default date chosen for input.
#' @param min Minimum date that can be selected.
#' @param max Maximum date that can be selected.
#' @param icon Icon that should be displayed on widget.
#' @param width character width of the object
#' @param ... other arguments
#'
#' @rdname date_input
#' @export
dateInput <- function(inputId, label = NULL, icon = NULL, value = NULL,
min = NULL, max = NULL, width = NULL, ...) {
dateInput <- function(inputId, label = NULL, value = NULL, min = NULL, max = NULL, width = NULL, ...) {
# TODO match arguments with shiny::dateInput
args_list <- list(...)
args_list$input_id <- inputId
args_list$label <- label
args_list$icon_name <- icon
args_list$value <- value
args_list$min <- min
args_list$max <- max
Expand Down
8 changes: 1 addition & 7 deletions man/date_input.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat/test_date_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ test_that("test dateInput missing input", {

test_that("test date_input output type", {
expect_is(date_input("date_from", value = Sys.Date()),
"shiny.tag.list")
"shiny.tag")
})

test_that("test dateInput output type", {
expect_is(date_input("date_from", value = Sys.Date()),
"shiny.tag.list")
"shiny.tag")
})

test_that("test date_input equals dateInput", {
Expand All @@ -29,7 +29,7 @@ test_that("test date_input basic input", {
si_str <- as.character(
date_input("date_from", value = Sys.Date())
)
expect_true(any(grepl(paste0("data-value=\"", as.character(Sys.Date()), "\""),
expect_true(any(grepl(paste0("data-date=\"", gsub("-", "/", as.character(Sys.Date())), "\""),
si_str, fixed = TRUE)))
# here we chaeck if style param is passed correctly
si_str <- as.character(
Expand Down