@@ -84,9 +84,6 @@ reset <- function(id = "", asis = FALSE) {
84
84
lapply(
85
85
names(messages ),
86
86
function (x ) {
87
- type <- messages [[x ]][[' type' ]]
88
- value <- messages [[x ]][[' value' ]]
89
-
90
87
# Make sure reset works with namespacing (shiny modules)
91
88
id <- x
92
89
if (substring(id , 1 , nchar(nsName )) == nsName ) {
@@ -100,11 +97,13 @@ reset <- function(id = "", asis = FALSE) {
100
97
}
101
98
funcParams <- list (session_to_reset , id )
102
99
100
+ type <- messages [[x ]][[' type' ]]
101
+ value <- messages [[x ]][[' value' ]]
102
+
103
103
# checkbox values need to be manually converted to TRUE/FALSE
104
104
if (type == " Checkbox" ) {
105
105
value <- as.logical(value )
106
106
}
107
-
108
107
if (type == " Date" ) {
109
108
if (value == " NA" ) {
110
109
value <- NA
@@ -144,16 +143,7 @@ reset <- function(id = "", asis = FALSE) {
144
143
funcParams [[' value' ]] <- value
145
144
}
146
145
147
- updateFunc <- sprintf(" update%sInput" , type )
148
-
149
- # radio buttons don't follow the regular shiny input naming conventions
150
- if (type == " RadioButtons" ) {
151
- updateFunc <- sprintf(" update%s" , type )
152
- }
153
- # for colour inputs, need to use the colourpicker package
154
- else if (type == " Colour" ) {
155
- updateFunc <- utils :: getFromNamespace(updateFunc , " colourpicker" )
156
- }
146
+ updateFunc <- getUpdateFunc(type )
157
147
158
148
# update the input to its original values
159
149
do.call(updateFunc , funcParams )
@@ -163,3 +153,22 @@ reset <- function(id = "", asis = FALSE) {
163
153
164
154
invisible (NULL )
165
155
}
156
+
157
+ getUpdateFunc <- function (type ) {
158
+ updateFunc <- sprintf(" update%sInput" , type )
159
+ updateFuncAlt <- sprintf(" update%s" , type )
160
+ pkg <- " "
161
+
162
+ if (type == " RadioButtons" ) {
163
+ updateFunc <- updateFuncAlt
164
+ }
165
+ else if (type == " Colour" ) {
166
+ pkg <- " colourpicker"
167
+ }
168
+
169
+ if (pkg != " " ) {
170
+ updateFunc <- utils :: getFromNamespace(updateFunc , pkg )
171
+ }
172
+
173
+ updateFunc
174
+ }
0 commit comments