insightsengineering / insightsengineering/teal

Filter mapping by module ID instead of module label

Open
#969 8 comments 0 reactions 0 assignees View on GitHub
core enhancement refine
Dominant language
R
Stars
263
Forks
59
Avg merge
5d 17h
Merged PRs (30d)
5

Description

Conceptually, I find it quite odd to map filter to module _labels_. It should be a module _identifier_ instead. A label should be a free text but we tend to use it as identifier which is probably not the right thing to do.

@donyunardi comment from #972

Currently, this is how users define module specific mapping

```r
app <- init(
data = cdisc_data(...),
modules = teal::modules(
teal.modules.general::tm_data_table(
label = "ADS Data Table",
variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX", "COUNTRY")),
dt_args = list(caption = "ADSL Table Caption")
),
filter = teal_slices(
teal_slice("ADSL", "COUNTRY", "country", selected = "USA", fixed = TRUE),
teal_slice("ADSL", "ETHNIC", "ethnic", anchored = TRUE),
module_specific = TRUE,
mapping = list(
"ADS Data Table" = c("country", "ethnic") # using the module's label to assign filters
)
)
)
```

We have an assertion to check for duplicate labels, which is good.

However, can we explore the possibility of using a module's `id` for this assignment? This could involve altering the module's structure and introducing the `id` in the module's server.

Here's what the code could look like:
```r
app <- init(
data = cdisc_data(...),
modules = teal::modules(
teal.modules.general::tm_data_table(
id = "module1",
label = "ADS Data Table",
variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX", "COUNTRY")),
dt_args = list(caption = "ADSL Table Caption")
),
filter = teal_slices(
teal_slice("ADSL", "COUNTRY", "country", selected = "USA", fixed = TRUE),
teal_slice("ADSL", "ETHNIC", "ethnic", anchored = TRUE),
module_specific = TRUE,
mapping = list(
"module1" = c("country", "ethnic") # using the module's id to assign filters
)
)
)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.