Skip to content

Commit

Permalink
211073 implement user feedback (#9)
Browse files Browse the repository at this point in the history
* add actionButton to reset all filters

* add buttons to select all, remove all and reset to default cols

* add shiny test and update docs

* run styler

* style mod_listings

* add vertical scrollbar for selectizeInput

* update select, unselect and reset to default cols mod_listing tests

* run styler

* split tests up test-mod_listing

* run styler

* fix failing mock_table_mm test-mod_listing

* run styler

* add test for reset filters

* run styler

* fix test label

* fix reset filters test-mod_listing.R

* run styler

* Update tests/testthat/test-mod_listing.R

Co-authored-by: Isabel Glauß <[email protected]>

* sync specs with tests, update NEWS.md, add more icons.

* Increment version number to 4.0.1

* update bookmarking exclusions

---------

Co-authored-by: Korbinian Matthias <[email protected]>
Co-authored-by: s1nghgurj <[email protected]>
Co-authored-by: Isabel Glauß <[email protected]>
  • Loading branch information
4 people authored Nov 29, 2024
1 parent 6cd2c86 commit e0d4062
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 37 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dv.listings
Type: Package
Title: Data listings module
Version: 4.0.0
Version: 4.0.1
Authors@R:
c(
person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# dv.listings 4.0.1

The module allows now to
- select all columns
- unselect all columns
- reset to default columns
- reset filters

# dv.listings 4.0.0

Package was renamed to dv.listings.
Expand Down
6 changes: 5 additions & 1 deletion R/mod_export_listings.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ mod_export_listings_UI <- function(module_id) { # nolint
shinyFeedback::useShinyFeedback(), # needed to use shinyFeedback functionalities
shinyjs::useShinyjs(), # needed to use shinyjs functionalities

shiny::actionButton(ns(EXP$EXPORTBTN_ID), label = EXP$EXPORTBTN_LABEL)
shiny::actionButton(
ns(EXP$EXPORTBTN_ID),
label = EXP$EXPORTBTN_LABEL,
icon = shiny::icon("download")
)
)

return(ui)
Expand Down
140 changes: 114 additions & 26 deletions R/mod_listings.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ TBL <- pack_of_constants( # nolint
DRPDBUTTON_LABEL = "Click to see inputs",
TABLE_ID = "listing",
NO_COL_MSG = "Please select at least one column.",
EXPORT_ID = "export"
EXPORT_ID = "export",
RESET_FILT_BUTTON_ID = "reset_filt_btn",
RESET_FILT_BUTTON_LABEL = "Reset all filters",
SELECT_ALL_COLS_BUTTON_ID = "select_all_cols_btn",
SELECT_ALL_COLS_BUTTON_LABEL = "Select all variables",
REMOVE_ALL_COLS_BUTTON_ID = "remove_all_cols_btn",
REMOVE_ALL_COLS_BUTTON_LABEL = "Remove all variables",
RESET_COLS_DEFAULT_BUTTON_ID = "reset_cols_btn",
RESET_COLS_DEFAULT_BUTTON_LABEL = "Reset to default variables"
)

#' A module that displays datasets as listings
Expand All @@ -29,26 +37,55 @@ listings_UI <- function(module_id) { # nolint

shiny::tagList(
shiny::fluidRow(
shiny::column(2, shinyWidgets::dropdownButton(
inputId = ns(TBL$DRPDBUTTON_ID),
shiny::selectizeInput(ns(TBL$DATASET_ID), label = TBL$DATASET_LABEL, choices = NULL),
shiny::selectizeInput(
ns(TBL$COLUMNS_ID),
label = TBL$COLUMNS_LABEL,
choices = NULL,
multiple = TRUE,
options = list(plugins = list("remove_button", "drag_drop"))
),
circle = FALSE,
icon = shiny::icon("cog"),
width = TBL$DRPDBUTTON_WIDTH,
label = TBL$DRPDBUTTON_LABEL,
tooltip = shinyWidgets::tooltipOptions(title = TBL$DRPDBUTTON_LABEL)
)),
shiny::column(
2,
shinyWidgets::dropdownButton(
inputId = ns(TBL$DRPDBUTTON_ID),
shiny::selectizeInput(ns(TBL$DATASET_ID), label = TBL$DATASET_LABEL, choices = NULL),
shiny::tags[["style"]](shiny::HTML(paste0(
"#",
ns(TBL$COLUMNS_ID),
" + div.selectize-control div.selectize-input.items {max-height:250px; overflow-y:auto;}"
))),
shiny::selectizeInput(
ns(TBL$COLUMNS_ID),
label = TBL$COLUMNS_LABEL,
choices = NULL,
multiple = TRUE,
options = list(plugins = list("remove_button", "drag_drop"))
),
shiny::actionButton(
ns(TBL$SELECT_ALL_COLS_BUTTON_ID),
TBL$SELECT_ALL_COLS_BUTTON_LABEL,
icon = shiny::icon("check-double")
),
shiny::actionButton(
ns(TBL$REMOVE_ALL_COLS_BUTTON_ID),
TBL$REMOVE_ALL_COLS_BUTTON_LABEL,
icon = shiny::icon("xmark")
),
shiny::actionButton(
ns(TBL$RESET_COLS_DEFAULT_BUTTON_ID),
TBL$RESET_COLS_DEFAULT_BUTTON_LABEL,
icon = shiny::icon("rotate-left")
),
circle = FALSE,
icon = shiny::icon("cog"),
width = TBL$DRPDBUTTON_WIDTH,
label = TBL$DRPDBUTTON_LABEL,
tooltip = shinyWidgets::tooltipOptions(title = TBL$DRPDBUTTON_LABEL)
)
),
shiny::column(2, mod_export_listings_UI(module_id = ns(TBL$EXPORT_ID)), offset = 8)
),
shiny::br(),
DT::dataTableOutput(ns(TBL$TABLE_ID), height = "80vh")
shiny::actionButton(
ns(TBL$RESET_FILT_BUTTON_ID),
TBL$RESET_FILT_BUTTON_LABEL,
icon = shiny::icon("filter-circle-xmark")
),
shiny::br(),
DT::dataTableOutput(ns(TBL$TABLE_ID), height = "80vh"),
)
}

Expand Down Expand Up @@ -102,6 +139,9 @@ listings_server <- function(module_id,
dataset_list()
})

# Set choices as a reactive value item
rvs <- shiny::reactiveValues(dataset_choices = NA, variable_choices = NA)

# Listing selection (start)
shiny::observeEvent(v_dataset_list(), {
# Fill default in case bookmark or default columns do not have all the listings in the dataset
Expand All @@ -114,10 +154,10 @@ listings_server <- function(module_id,
}
bmk_dataset <<- NULL

choices <- generate_choices(v_dataset_list())
shiny::exportTestValues(dataset_choices = choices) # Export values for shinytest2 tests
rvs$dataset_choices <- generate_choices(v_dataset_list())
shiny::exportTestValues(dataset_choices = rvs$dataset_choices) # Export values for shinytest2 tests

shiny::updateSelectizeInput(inputId = TBL$DATASET_ID, choices = choices, selected = selected)
shiny::updateSelectizeInput(inputId = TBL$DATASET_ID, choices = rvs$dataset_choices, selected = selected)
})

listings_data <- shiny::reactive({
Expand Down Expand Up @@ -146,19 +186,49 @@ listings_server <- function(module_id,
)
}

choices <- generate_choices(listings_data())
rvs$variable_choices <- generate_choices(listings_data())

shiny::updateSelectizeInput(
inputId = TBL$COLUMNS_ID,
choices = choices,
choices = rvs$variable_choices,
selected = r_selected_columns_in_dataset()[[input[[TBL$DATASET_ID]]]]
)
}
)

shiny::observeEvent(input[[TBL$SELECT_ALL_COLS_BUTTON_ID]], {
shiny::updateSelectizeInput(
inputId = TBL$COLUMNS_ID,
choices = rvs$variable_choices,
selected = rvs$variable_choices
)
})

shiny::observeEvent(input[[TBL$REMOVE_ALL_COLS_BUTTON_ID]], {
shiny::updateSelectizeInput(
inputId = TBL$COLUMNS_ID,
choices = rvs$variable_choices,
selected = NULL
)
})

shiny::observeEvent(input[[TBL$RESET_COLS_DEFAULT_BUTTON_ID]], {
r_selected_columns_in_dataset(
fill_default_vars(default_vars, v_dataset_list())
)
shiny::updateSelectizeInput(
inputId = TBL$COLUMNS_ID,
choices = rvs$variable_choices,
selected = r_selected_columns_in_dataset()[[input[[TBL$DATASET_ID]]]]
)
})


shiny::observeEvent(input[[TBL$COLUMNS_ID]], {
selected_columns_in_dataset <- r_selected_columns_in_dataset()
selected_columns_in_dataset[[input[[TBL$DATASET_ID]]]] <- input[[TBL$COLUMNS_ID]]
selected_columns_in_dataset[[input[[TBL$DATASET_ID]]]] <- input[[
TBL$COLUMNS_ID
]]
r_selected_columns_in_dataset(selected_columns_in_dataset)
})

Expand Down Expand Up @@ -190,7 +260,15 @@ listings_server <- function(module_id,
"table_rows_selected",
"table_cells_selected",
"table_columns_selected",
"table_state"
"table_state",
"select_all_cols_btn",
"remove_all_cols_btn",
"reset_cols_btn",
"download_data",
"reset_filt_btn",
"download_data",
"dropdown_btn",
"clear_filters"
))

# Bookmarking (end)
Expand All @@ -205,6 +283,10 @@ listings_server <- function(module_id,
intended_use_label = intended_use_label
)

# Proxy reference to dataTable
dt_proxy <- DT::dataTableProxy(TBL$TABLE_ID)
shiny::observeEvent(input[[TBL$RESET_FILT_BUTTON_ID]], DT::clearSearch(dt_proxy))

output[[TBL$TABLE_ID]] <- DT::renderDataTable({
shiny::validate(shiny::need(!is.null(input[[TBL$COLUMNS_ID]]), TBL$NO_COL_MSG))

Expand Down Expand Up @@ -251,7 +333,13 @@ listings_server <- function(module_id,
ordering = TRUE,
columnDefs = list(list(className = "dt-center", targets = "_all")),
dom = "Bfrtilp",
buttons = list(list(extend = "collection", text = "Reset Rows Order", action = htmlwidgets::JS(js)))
buttons = list(
list(
extend = "collection",
text = "Reset rows order",
action = htmlwidgets::JS(js)
)
)
)
)
})
Expand Down
6 changes: 5 additions & 1 deletion inst/validation/specs.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ listing <- specs_list(
"restore_row_order" = "dv.listings includes a button to restore the row order of a listing to the state as it is in the original data.",
"default_vars" = "If pre-specifications for default columns are available, dv.listings will display them at app launch for the respective listing. If not, dv.listings will show the first six columns of the listing - or all columns, in case the number of columns is less than six.",
"retain_last_selection" = "dv.listings can remember and retain the last column selections after switching listings during the current session. It also restores the remembered selections for all listings after bookmarking.",
"bookmarking" = "The module is compatible with the bookmarking feature of the dv.manager."
"bookmarking" = "The module is compatible with the bookmarking feature of the dv.manager.",
"select_all_columns" = "dv.listings includes functionality to select all the columns.",
"unselect_all_columns" = "dv.listings includes functionality to unselect all the columns.",
"reset_columns" = "dv.listings includes includes functionality to reset to the default columns.",
"reset_filters" = "dv.listings includes functionality to reset all filters."
)
export <- specs_list(
"export" = "dv.listings includes a button to export the listing(s). A click to the button envokes a pop-up to appear that allows the user to decide whether the download should only contain the displayed listing or all available listings, provide a file name (defaulted to the dataset name), and select from available file types.",
Expand Down
Binary file modified man/figures/table_main_view.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e0d4062

Please sign in to comment.