Skip to content

Commit

Permalink
fix progress bar js error
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Feb 21, 2024
1 parent 3660e04 commit 434ca51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
37 changes: 19 additions & 18 deletions R/progressBars.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,22 @@ progressBar <- function(id,
title, HTML("&nbsp;")
)

if (commas) {
value_for_display <- format_display(value)
total_for_display <- format_display(total)
} else {
value_for_display <- value
total_for_display <- total
}
value_for_display <- format_display(value)
total_for_display <- format_display(total)

if (!is.null(total)) {
total <- tagList(
tags$span(
class = "progress-number float-right float-end",
tags$b(value_for_display, id = paste0(id, "-value")),
"/",
tags$span(id = paste0(id, "-total"), total_for_display)
),
tags$div(class = "clearfix")
)

}
total <- tagList(
tags$span(
class = "progress-number pull-right float-end",
style = css(display = if (is.null(total)) "none"),
tags$b(value_for_display, id = paste0(id, "-value")),
"/",
tags$span(id = paste0(id, "-total"), total_for_display)
),
tags$div(class = "clearfix")
)

tagPB <- tags$div(
class = "progress-group",
Expand Down Expand Up @@ -172,8 +169,10 @@ updateProgressBar <- function(session = getDefaultReactiveDomain(),
status = NULL,
range_value = NULL,
commas = TRUE,
format_display = function(value) {
prettyNum(value, big.mark = ",", scientific = FALSE)
},
unit_mark = "%") {
message <- "update-progressBar-shinyWidgets"
if (!is.null(range_value)) {
percent <- rescale(x = value, from = range_value, to = c(0, 100))
} else {
Expand All @@ -186,12 +185,14 @@ updateProgressBar <- function(session = getDefaultReactiveDomain(),
id <- session$ns(id)
}
session$sendCustomMessage(
type = message,
type = "update-progressBar-shinyWidgets",
message = list(
id = id,
value = value,
percent = percent,
total = if (is.null(total)) -1 else total,
value_display = format_display(value),
total_display = format_display(total),
title = as.character(title),
status = status,
commas = commas,
Expand Down
4 changes: 4 additions & 0 deletions man/progress-bar.Rd

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

0 comments on commit 434ca51

Please sign in to comment.