From 9ad50bc545e4efba25bf776ee001f2849b15bb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:09:54 +0100 Subject: [PATCH 1/2] fix: remove hardcoded on validation to correct #561 --- R/tm_outliers.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/tm_outliers.R b/R/tm_outliers.R index c565e16ec..4fe7c22a1 100644 --- a/R/tm_outliers.R +++ b/R/tm_outliers.R @@ -252,12 +252,12 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var, moduleServer(id, function(input, output, session) { vars <- list(outlier_var = outlier_var, categorical_var = categorical_var) - rule_diff <- function(other) { + rule_diff <- function(other, other_label, var_label) { function(value) { - othervalue <- tryCatch(selector_list()[["categorical_var"]]()[["select"]], error = function(e) NULL) + othervalue <- tryCatch(selector_list()[[other]]()[["select"]], error = function(e) NULL) if (!is.null(othervalue)) { if (identical(othervalue, value)) { - "`Variable` and `Categorical factor` cannot be the same" + paste0("`", var_label, "` and `", other_label, "` cannot be the same") } } } @@ -269,9 +269,9 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var, select_validation_rule = list( outlier_var = shinyvalidate::compose_rules( shinyvalidate::sv_required("Please select a variable"), - rule_diff("categorical_var") + rule_diff("categorical_var", "Categorical factor", "Variable") ), - categorical_var = rule_diff("outlier_var") + categorical_var = rule_diff("outlier_var", "Variable", "Categorical factor") ) ) From 6e6ce0f891562c618a1efb2380d2ba2ba4082eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:46:59 +0100 Subject: [PATCH 2/2] chore: revert to hardcoded message see https://github.com/insightsengineering/teal.modules.general/pull/562\#pullrequestreview-1567322146 --- R/tm_outliers.R | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/R/tm_outliers.R b/R/tm_outliers.R index 4fe7c22a1..28f06fd33 100644 --- a/R/tm_outliers.R +++ b/R/tm_outliers.R @@ -252,13 +252,11 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var, moduleServer(id, function(input, output, session) { vars <- list(outlier_var = outlier_var, categorical_var = categorical_var) - rule_diff <- function(other, other_label, var_label) { + rule_diff <- function(other) { function(value) { othervalue <- tryCatch(selector_list()[[other]]()[["select"]], error = function(e) NULL) - if (!is.null(othervalue)) { - if (identical(othervalue, value)) { - paste0("`", var_label, "` and `", other_label, "` cannot be the same") - } + if (!is.null(othervalue) && identical(othervalue, value)) { + "`Variable` and `Categorical factor` cannot be the same" } } } @@ -269,9 +267,9 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var, select_validation_rule = list( outlier_var = shinyvalidate::compose_rules( shinyvalidate::sv_required("Please select a variable"), - rule_diff("categorical_var", "Categorical factor", "Variable") + rule_diff("categorical_var") ), - categorical_var = rule_diff("outlier_var", "Variable", "Categorical factor") + categorical_var = rule_diff("outlier_var") ) )