Skip to content

Commit 2f9f79b

Browse files
committed
feat: use common function to normalize decorators
1 parent ea8d583 commit 2f9f79b

12 files changed

+40
-87
lines changed

R/tm_a_pca.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,8 @@ tm_a_pca <- function(label = "Principal Component Analysis",
165165
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
166166
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
167167

168-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
169-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
170-
lapply(decorators, list)
171-
} else {
172-
list(default = decorators)
173-
}
174-
}
175-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
168+
decorators <- normalize_decorators(decorators)
169+
assert_decorators(decorators, null.ok = TRUE)
176170
# End of assertions
177171

178172
# Make UI args

R/tm_data_table.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,8 @@ tm_data_table <- function(label = "Data Table",
131131
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
132132
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
133133

134-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
135-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
136-
lapply(decorators, list)
137-
} else {
138-
list(default = decorators)
139-
}
140-
}
141-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
134+
decorators <- normalize_decorators(decorators)
135+
assert_decorators(decorators, null.ok = TRUE)
142136
# End of assertions
143137

144138
ans <- module(

R/tm_g_association.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,8 @@ tm_g_association <- function(label = "Association",
176176
checkmate::assert_list(ggplot2_args, types = "ggplot2_args")
177177
checkmate::assert_subset(names(ggplot2_args), c("default", plot_choices))
178178

179-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
180-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
181-
lapply(decorators, list)
182-
} else {
183-
list(default = decorators)
184-
}
185-
}
186-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
179+
decorators <- normalize_decorators(decorators)
180+
assert_decorators(decorators, null.ok = TRUE)
187181

188182
# End of assertions
189183

R/tm_g_bivariate.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,8 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
276276
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
277277
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
278278

279-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
280-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
281-
lapply(decorators, list)
282-
} else {
283-
list(default = decorators)
284-
}
285-
}
286-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
279+
decorators <- normalize_decorators(decorators)
280+
assert_decorators(decorators, null.ok = TRUE)
287281
# End of assertions
288282

289283
# Make UI args

R/tm_g_distribution.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,8 @@ tm_g_distribution <- function(label = "Distribution Module",
201201
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
202202
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
203203

204-
available_decorators <- c("default", "plot", "test_table", "summary_table")
205-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
206-
decorators <- if (checkmate::test_names(names(decorators), subset.of = available_decorators)) {
207-
lapply(decorators, list)
208-
} else {
209-
list(default = decorators)
210-
}
211-
}
204+
available_decorators <- c("plot", "test_table", "summary_table")
205+
decorators <- normalize_decorators(decorators, available_decorators)
212206
assert_decorators(decorators, null.ok = TRUE, names = available_decorators)
213207

214208
# End of assertions

R/tm_g_response.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,8 @@ tm_g_response <- function(label = "Response Plot",
201201
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
202202
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
203203

204-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
205-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
206-
lapply(decorators, list)
207-
} else {
208-
list(default = decorators)
209-
}
210-
}
211-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
204+
decorators <- normalize_decorators(decorators)
205+
assert_decorators(decorators, null.ok = TRUE)
212206
# End of assertions
213207

214208
# Make UI args

R/tm_g_scatterplot.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,8 @@ tm_g_scatterplot <- function(label = "Scatterplot",
308308
checkmate::assert_scalar(table_dec)
309309
checkmate::assert_class(ggplot2_args, "ggplot2_args")
310310

311-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
312-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
313-
lapply(decorators, list)
314-
} else {
315-
list(default = decorators)
316-
}
317-
}
318-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
311+
decorators <- normalize_decorators(decorators)
312+
assert_decorators(decorators, null.ok = TRUE)
319313

320314
# End of assertions
321315

R/tm_g_scatterplotmatrix.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,8 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
203203
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
204204
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
205205

206-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
207-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default"))) {
208-
lapply(decorators, list)
209-
} else {
210-
list(default = decorators)
211-
}
212-
}
213-
assert_decorators(decorators, null.ok = TRUE, names = c("default"))
206+
decorators <- normalize_decorators(decorators)
207+
assert_decorators(decorators, null.ok = TRUE)
214208
# End of assertions
215209

216210
# Make UI args

R/tm_missing_data.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,8 @@ tm_missing_data <- function(label = "Missing data",
135135
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
136136

137137
available_decorators <- c("summary_plot", "summary_plot", "combination_plot", "by_subject_plot", "summary_table")
138-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
139-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default", available_decorators))) {
140-
lapply(decorators, list)
141-
} else {
142-
list(default = decorators)
143-
}
144-
}
145-
assert_decorators(decorators, null.ok = TRUE, names = c("default", available_decorators))
138+
decorators <- normalize_decorators(decorators, available_decorators)
139+
assert_decorators(decorators, null.ok = TRUE, names = available_decorators)
146140
# End of assertions
147141

148142
ans <- module(

R/tm_outliers.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,7 @@ tm_outliers <- function(label = "Outliers Module",
179179
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
180180

181181
available_decorators <- c("box_plot", "density_plot", "cumulative_plot", "table")
182-
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
183-
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default", available_decorators))) {
184-
lapply(decorators, list)
185-
} else {
186-
list(default = decorators)
187-
}
188-
}
182+
decorators <- normalize_decorators(decorators, available_decorators)
189183
assert_decorators(decorators, null.ok = TRUE, names = available_decorators)
190184
# End of assertions
191185

0 commit comments

Comments
 (0)