Skip to content
Open
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
5 changes: 0 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tfrmtbuilder
Title: 'shiny' App Companion to the 'tfrmt' Package
Version: 0.1.0
Version: 0.1.1
Authors@R:
c(person(given = "Becca",
family = "Krouse",
Expand Down Expand Up @@ -29,13 +29,12 @@ Description: Provides an interactive interface to the 'tfrmt' package. Users
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Imports:
tfrmt (>= 0.1.0),
shiny,
shinyjs,
dplyr,
forcats,
stringr,
purrr,
DT,
Expand Down
33 changes: 4 additions & 29 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,13 @@
export(tfrmtbuilder)
import(bslib)
import(dplyr)
import(forcats)
import(gt)
import(purrr)
import(shiny)
import(shinyAce)
import(shinyWidgets)
import(sortable)
import(stringr)
import(tfrmt)
import(webshot2)
importFrom(DT,DTOutput)
importFrom(DT,datatable)
importFrom(DT,renderDT)
importFrom(fontawesome,fa_i)
importFrom(rio,import)
importFrom(rlang,`!!`)
importFrom(rlang,`:=`)
importFrom(rlang,as_label)
importFrom(rlang,is_empty)
importFrom(rlang,quo)
importFrom(rlang,quo_is_missing)
importFrom(shinyFeedback,feedbackDanger)
importFrom(shinyFeedback,useShinyFeedback)
importFrom(shinycssloaders,withSpinner)
importFrom(shinyjs,addClass)
importFrom(shinyjs,disable)
importFrom(shinyjs,enable)
importFrom(shinyjs,hide)
importFrom(shinyjs,onclick)
importFrom(shinyjs,removeClass)
importFrom(shinyjs,show)
importFrom(shinyjs,toggle)
importFrom(shinyjs,toggleClass)
importFrom(shinyjs,toggleState)
importFrom(shinyjs,useShinyjs)
importFrom(stats,setNames)
importFrom(utils,getFromNamespace)
importFrom(utils,zip)
importFrom(rlang,sym)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# tfrmtbuilder 0.1.1

* Bug fixes:
- Fix namespace conflict between bslib and shinyWidgets

# tfrmtbuilder 0.1.0

* New features:
Expand Down
2 changes: 1 addition & 1 deletion R/mod_big_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ big_n_server <- function(id, data, tfrmt_app, mode_load){
})

# when any are selected, switch to edit mode
onclick("items", expr = {
shinyjs::onclick("items", expr = {

if (!is_empty(struct())){
mode("edit")
Expand Down
4 changes: 2 additions & 2 deletions R/mod_big_n_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ big_n_edit_ui <- function(id){
fluidRow(
div(style = " width: 50%;",
div(id = ns("frmt_outer"),
aceEditor(ns("frmt"), mode = "r", fontSize = 16, value = "frmt(\"\\nN = xx\")",
shinyAce::aceEditor(ns("frmt"), mode = "r", fontSize = 16, value = "frmt(\"\\nN = xx\")",
wordWrap = TRUE,
minLines = 2,
maxLines = 2,
Expand Down Expand Up @@ -60,7 +60,7 @@ big_n_edit_server <- function(id, data, tfrmt_app, selected, mode_load){

}

updateAceEditor(session,
shinyAce::updateAceEditor(session,
editorId = "frmt",
value = existing_frmt)
})
Expand Down
6 changes: 3 additions & 3 deletions R/mod_body_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ body_plan_server <- function(id, data, tfrmt_app, mode_load){

req(length(struct_list())>0)

struct_list_txt <- map(struct_list(),
struct_list_txt <- purrr::map(struct_list(),
~.x %>% format_frmt_struct() %>% {paste0(., collapse = "<br>")})

create_struct_list_sortable(ns, struct_list_txt, mode())
Expand All @@ -104,9 +104,9 @@ body_plan_server <- function(id, data, tfrmt_app, mode_load){


# when any are selected, switch to edit mode
onclick("items", expr = {
shinyjs::onclick("items", expr = {

last_struct <- pluck(struct_list(), length(struct_list()))
last_struct <- purrr::pluck(struct_list(), length(struct_list()))
if(!is_empty(last_struct)){
mode("edit")
}
Expand Down
2 changes: 1 addition & 1 deletion R/mod_body_plan_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ body_plan_edit_server <- function(id, data, tfrmt_app, selected){

if (!all(collected_filters()$param_val==".default") &&
length(collected_filters()$param_val)==1){
frmt_out_ready <- setNames(frmt_out_ready, collected_filters()$param_val)
frmt_out_ready <- purrr::set_names(frmt_out_ready, collected_filters()$param_val)
}

do.call("frmt_structure", args = c(list(group_val = collected_filters()$group_val,
Expand Down
6 changes: 3 additions & 3 deletions R/mod_body_plan_edit_frmts.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ body_plan_edit_frmts_ui <- function(id){
fluidRow(
div(style = "margin-top:20px; width: 75%",
div(id = ns("frmt_outer"),
aceEditor(ns("frmt"), mode = "r", fontSize = 16, value = "frmt('XXX.X')",
shinyAce::aceEditor(ns("frmt"), mode = "r", fontSize = 16, value = "frmt('XXX.X')",
wordWrap = TRUE,
minLines = 5,
maxLines = 8,
Expand Down Expand Up @@ -60,7 +60,7 @@ body_plan_edit_frmts_server <- function(id, selected){

}

updateAceEditor(session,
shinyAce::updateAceEditor(session,
editorId = "frmt",
value = existing_frmt)
})
Expand All @@ -73,7 +73,7 @@ body_plan_edit_frmts_server <- function(id, selected){
observeEvent(input[[paste0("pst_", x)]],{

dummy_fun <- get(paste0("dummy_", x), envir = asNamespace("tfrmtbuilder"))
updateAceEditor(session,
shinyAce::updateAceEditor(session,
editorId = "frmt",
value = paste0(input$frmt, dummy_fun()))
})
Expand Down
6 changes: 3 additions & 3 deletions R/mod_col_plan_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ col_plan_simple_server <- function(id, data, tfrmt_app, mode_load){

# group/label order for tfrmt
grp_lbl_ord <- eventReactive(tfrmt_app(),{
c(tfrmt_app()$group %>% map_chr(as_label),
c(tfrmt_app()$group %>% purrr::map_chr(as_label),
tfrmt_app()$label %>% as_label())
})

Expand Down Expand Up @@ -143,7 +143,7 @@ col_plan_simple_server <- function(id, data, tfrmt_app, mode_load){
selected <- reactiveVal(NULL)
selected_num <- reactiveVal(NULL)

onclick("items", expr = {
shinyjs::onclick("items", expr = {
mode("edit")
item_num <- as.numeric(input$`button-item`)

Expand Down Expand Up @@ -196,7 +196,7 @@ col_plan_simple_server <- function(id, data, tfrmt_app, mode_load){
eventReactive(cols_dat_out(),{

new_name_col <- paste0("__tfrmt_new_name__", col_name())
col <- tfrmt_app()$column %>% map_chr(as_label)
col <- tfrmt_app()$column %>% purrr::map_chr(as_label)
cols_to_keep <- cols_dat_out() %>%
filter(!.data$`__col_plan_dropped__`)

Expand Down
6 changes: 3 additions & 3 deletions R/mod_col_style_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ col_style_plan_server <- function(id, data, tfrmt_app){

req(length(struct_list())>0)

struct_list_txt <- map(struct_list(),
struct_list_txt <- purrr::map(struct_list(),
~.x %>% format_col_style_struct() %>% {paste0(., collapse = "<br>")})

create_struct_list_sortable(ns, struct_list_txt, mode())
Expand All @@ -104,9 +104,9 @@ col_style_plan_server <- function(id, data, tfrmt_app){


# when any are selected, switch to edit mode
onclick("items", expr = {
shinyjs::onclick("items", expr = {

last_struct <- pluck(struct_list(), length(struct_list()))
last_struct <- purrr::pluck(struct_list(), length(struct_list()))
if(!is_empty(last_struct)){
mode("edit")
}
Expand Down
6 changes: 3 additions & 3 deletions R/mod_col_style_plan_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ col_style_plan_edit_ui <- function(id){
fluidRow(
column(6,
h3("Align"),
awesomeRadio(ns("align_opts"), label = NULL,
shinyWidgets::awesomeRadio(ns("align_opts"), label = NULL,
choices = list("left", "right", "custom"),
inline = TRUE,
selected = "left"),
Expand Down Expand Up @@ -61,14 +61,14 @@ col_style_plan_edit_server <- function(id, data, tfrmt_app, selected){
}

if (existing_align[[1]] %in% c("left","right")){
updateAwesomeRadio(session, inputId = "align_opts", selected = existing_align)
shinyWidgets::updateAwesomeRadio(session, inputId = "align_opts", selected = existing_align)
} else {

existing_align_txt <- paste0("\"", existing_align, "\"")
if (length(existing_align_txt)>1){
existing_align_txt <- paste0("c(", paste(existing_align_txt, collapse = ", "), ")")
}
updateAwesomeRadio(session, inputId = "align_opts", selected = "custom")
shinyWidgets::updateAwesomeRadio(session, inputId = "align_opts", selected = "custom")
updateTextInput(session, inputId = "align_custom", value = existing_align_txt)
}

Expand Down
10 changes: 5 additions & 5 deletions R/mod_datamapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ datamapping_server <- function(id, data, tfrmt_orig, mode){

nms <- c("group","label","param","value","column","sorting_cols")
tfrmt_orig()[nms] %>%
map(function(x){
purrr::map(function(x){
if (is.null(x)){
NULL
} else if (is.list(x)){
map_chr(x, as_label)
purrr::map_chr(x, as_label)
} else {
as_label(x)
}
}) %>%
setNames(nms)
purrr::set_names(nms)

})

Expand Down Expand Up @@ -221,10 +221,10 @@ datamapping_server <- function(id, data, tfrmt_orig, mode){

tf <- isolate(tfrmt_orig())

tfrmt_new <- do.call(tfrmt, settings_collected() %>% discard(is.null))
tfrmt_new <- do.call(tfrmt, settings_collected() %>% purrr::discard(is.null))

# update groups if needed
old_grps <- tf$group %>% map_chr(as_label)
old_grps <- tf$group %>% purrr::map_chr(as_label)
new_grps <- settings_collected()$group[1:length(old_grps)]

grps_to_update <- which(!old_grps==new_grps)
Expand Down
18 changes: 9 additions & 9 deletions R/mod_datamapping_inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ datamapping_inputs_ui <- function(id, setting_name){
div(
id = ns("item_div"),
span(id = ns("multiples"),
div(circleButton(ns("addinput"), icon = icon("plus"), size = "xs"), class = "btn-circle"),
div(circleButton(ns("dropinput"), icon = icon("minus"), size = "xs"), class = "btn-circle"),
div(shinyWidgets::circleButton(ns("addinput"), icon = icon("plus"), size = "xs"), class = "btn-circle"),
div(shinyWidgets::circleButton(ns("dropinput"), icon = icon("minus"), size = "xs"), class = "btn-circle"),
style = "display: flex; gap: 5px;")
)
)
Expand All @@ -37,7 +37,7 @@ datamapping_inputs_server <- function(id, data, settings_in, reset, multiple, re

# hide add/drop inputs if multiple = FALSE
observe({
toggle("multiples", condition = multiple==TRUE)
shinyjs::toggle("multiples", condition = multiple==TRUE)
})

# starts at zero, 1 for initial state, then increments for each edit
Expand All @@ -62,7 +62,7 @@ datamapping_inputs_server <- function(id, data, settings_in, reset, multiple, re

removeUI(paste0("#", ns("item_div_inputs")))

existing_inputs <- names(input)[str_detect(names(input), "^item-")]
existing_inputs <- names(input)[stringr::str_detect(names(input), "^item-")]
for (i in existing_inputs){
remove_shiny_inputs(ns, i, input)
}
Expand Down Expand Up @@ -139,7 +139,7 @@ datamapping_inputs_server <- function(id, data, settings_in, reset, multiple, re

vals <- lapply(expected_inputs, function(ind){
input[[ind]]
}) %>% set_names(expected_inputs)
}) %>% purrr::set_names(expected_inputs)

selected_items(vals)

Expand Down Expand Up @@ -182,15 +182,15 @@ datamapping_inputs_server <- function(id, data, settings_in, reset, multiple, re
expected_inputs <- paste0("item-", active_items())
req(all(expected_inputs %in% names(selected_items())))

imap(selected_items(), function(value, name){
purrr::imap(selected_items(), function(value, name){

show <- is.null(value)

feedbackDanger(inputId = name, color = "red", icon = NULL, text = NULL, show = show)
shinyFeedback::feedbackDanger(inputId = name, color = "red", icon = NULL, text = NULL, show = show)

})

if (any(map_lgl(selected_items(), is.null))){
if (any(purrr::map_lgl(selected_items(), is.null))){
settings_complete(FALSE)
} else {
settings_complete(TRUE)
Expand All @@ -201,7 +201,7 @@ datamapping_inputs_server <- function(id, data, settings_in, reset, multiple, re
# selected items out
settings <- reactive({
if (!is.null(selected_items())){
keep(selected_items(), function(x)!is.null(x)) %>% unlist() %>% unname()
purrr::keep(selected_items(), function(x)!is.null(x)) %>% unlist() %>% unname()
} else {
NULL
}
Expand Down
8 changes: 4 additions & 4 deletions R/mod_export_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ mod_export_table_server <- function(id, tbl, ext){
dir.create(temp_dir)

n_tbls <- nrow(tbl()$gt_tbls)
walk(1:n_tbls, function(x){
tbl() %>% grp_pull(x) %>% gtsave(filename = paste0("tfrmt_",x,".", tolower(ext)), path = temp_dir)
purrr::walk(1:n_tbls, function(x){
tbl() %>% gt::grp_pull(x) %>% gt::gtsave(filename = paste0("tfrmt_",x,".", tolower(ext)), path = temp_dir)
})

zip(
utils::zip(
zipfile = con,
files = file.path(temp_dir, paste0("tfrmt_", seq_along(tbl()), ".", tolower(ext))),
flags = "-r9Xj"
Expand All @@ -45,7 +45,7 @@ mod_export_table_server <- function(id, tbl, ext){
} else{

gtobj <- tbl()
gtsave(gtobj, con)
gt::gtsave(gtobj, con)

}
}
Expand Down
Loading