Skip to content

Commit

Permalink
Fixes #55
Browse files Browse the repository at this point in the history
- The plot is now synced all the tables.
- Correct a variable name. In config, `col_labels_for_participts` get renamed to `cols_to_remove_from_participts_table`.
  • Loading branch information
asiripanich committed Jul 24, 2021
1 parent 8ea545b commit 73a9bb0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
31 changes: 25 additions & 6 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,40 @@ app_server <- function(input, output, session) {

# Convert the config's label map to a named vector.
# The names are the original labels, and the vector values are the new labels.
named_label_vector <- unlist(getOption("emdash.col_labels_for_participts"))
originalColumnNames <- names(named_label_vector)
new_column_names <- unname(named_label_vector)
named_label_vector <- unlist(getOption("emdash.col_labels_for_participants"))
original_col_labels_for_participants <- names(named_label_vector)
new_col_labels_for_participants <- unname(named_label_vector)

observeEvent(input$tabs, {
if (input$tabs == "participants") {
data_esquisse$data <-
data_r$participants %>%
drop_list_columns() %>%
data.table::setnames(originalColumnNames, new_column_names, skip_absent = TRUE)
data.table::setnames(original_col_labels_for_participants, new_col_labels_for_participants, skip_absent = TRUE)
}

# Make sure trips exists before attempting to manipulate it
if (exists("data_geogr$trips") && input$tabs == "trips") {
if (!is.null(data_geogr$trips) && input$tabs == "trips") {
data_esquisse$data <-
data_geogr$trips %>%
drop_list_columns() %>%
sf::st_drop_geometry()
}

if (input$tabs %in% names(data_r)) {
data_esquisse$data <-
data_r[[input$tabs]] %>%
drop_list_columns()

if (input$tabs == "participants") {
data.table::setnames(
data_r[[input$tabs]],
original_col_labels_for_participants,
new_col_labels_for_participants,
skip_absent = TRUE
)
}
}
})

# INTERACTIVE PLOT PANEL
Expand All @@ -137,7 +152,11 @@ app_server <- function(input, output, session) {
callModule(mod_DT_server, "DT_ui_participants",
data = data_r$participants %>%
dplyr::select(-dplyr::any_of(getOption("emdash.cols_to_remove_from_participts_table"))) %>%
data.table::setnames(originalColumnNames, new_column_names, skip_absent = TRUE)
data.table::setnames(
original_col_labels_for_participants,
new_col_labels_for_participants,
skip_absent = TRUE
)
)

# For each supplementary table, append a new tabPanel and run the server function
Expand Down
2 changes: 1 addition & 1 deletion inst/config-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ default:


# Set the labels to display for the participant data
col_labels_for_participts:
col_labels_for_participants:
user_id: user id
update_ts: last profile update
client: UI channel
Expand Down

0 comments on commit 73a9bb0

Please sign in to comment.