Riksrevisjonen / pioneeR

R package for running a Shiny app for DEA analysis
https://riksrevisjonen.github.io/pioneeR/
GNU General Public License v3.0
6 stars 2 forks source link

Add function for default column definitions #108

Open ohjakobsen opened 3 months ago

ohjakobsen commented 3 months ago

For reactable tables, we could add a utility function that defines global definitions for columns that are used in multiple tables. This will reduce complexity in code, increase consistency and keep code more DRY.

Here is an example of such a utility function:

default_columns <- function(columns, column_definitions = list()) {
  defaults <- list(
    client = colDef(name = 'Klient', maxWidth = 100),
    comp_reg_no = colDef(name = 'Org.nr', maxWidth = 100),
    voucher_no = colDef(name = 'Bilag')
  )
  column_list <- defaults[columns[columns %in% names(defaults)]]
  return(modifyList(column_list, column_definitions))
}

_Originally posted by @ohjakobsen in https://github.com/Riksrevisjonen/pioneeR/pull/106#discussion_r1625770392_