fix: correct data loading
This commit is contained in:
@@ -264,6 +264,14 @@ update_forms_with_data = function(
|
||||
ns
|
||||
) {
|
||||
|
||||
box::use(modules/data_manipulations[is_this_empty_value])
|
||||
|
||||
# print("-----------------")
|
||||
# cli::cli_inform("form_id: {form_id} | form_type: {form_type}")
|
||||
# print(value)
|
||||
# print(typeof(value))
|
||||
# print(is_this_empty_value(value))
|
||||
|
||||
filterd_line <- scheme |>
|
||||
dplyr::filter(form_id == {{form_id}})
|
||||
|
||||
@@ -294,50 +302,58 @@ update_forms_with_data = function(
|
||||
new_choices <- unique(c(old_choices, value))
|
||||
new_choices <- new_choices[!is.na(new_choices)]
|
||||
|
||||
|
||||
shiny::updateSelectizeInput(inputId = form_id, selected = value, choices = new_choices)
|
||||
# shiny::updateSelectizeInput(inputId = form_id, selected = value)
|
||||
}
|
||||
|
||||
# select_multiple
|
||||
# check if value is not NA and split by delimetr
|
||||
if (form_type == "select_multiple" && !is.na(value)) {
|
||||
vars <- stringr::str_split_1(value, local_delimeter)
|
||||
if (form_type == "select_multiple") {
|
||||
if (is_this_empty_value(value)) {
|
||||
shiny::updateSelectizeInput(inputId = form_id, selected = as.character(0))
|
||||
} else {
|
||||
vars <- stringr::str_split_1(value, local_delimeter)
|
||||
|
||||
# update choices
|
||||
old_choices <- filterd_line$choices
|
||||
new_choices <- unique(c(old_choices, vars))
|
||||
new_choices <- new_choices[!is.na(new_choices)]
|
||||
|
||||
shiny::updateSelectizeInput(inputId = form_id, selected = vars, choices = new_choices)
|
||||
# shiny::updateSelectizeInput(inputId = form_id, selected = vars)
|
||||
}
|
||||
|
||||
# in other case fill with `character(0)` to proper reseting form
|
||||
if (form_type == "select_multiple" && is.na(value)) {
|
||||
shiny::updateSelectizeInput(inputId = form_id, selected = character(0))
|
||||
# update choices
|
||||
old_choices <- filterd_line$choices
|
||||
new_choices <- unique(c(old_choices, vars))
|
||||
new_choices <- new_choices[!is.na(new_choices)]
|
||||
shiny::updateSelectizeInput(inputId = form_id, selected = vars, choices = new_choices)
|
||||
}
|
||||
}
|
||||
|
||||
# radio buttons
|
||||
if (form_type == "radio" && !is.na(value)) {
|
||||
shiny::updateRadioButtons(inputId = form_id, selected = value)
|
||||
}
|
||||
if (form_type == "radio" && is.na(value)) {
|
||||
shiny::updateRadioButtons(inputId = form_id, selected = character(0))
|
||||
if (form_type == "radio") {
|
||||
if (is_this_empty_value(value)) {
|
||||
shiny::updateRadioButtons(inputId = form_id, selected = character(0))
|
||||
} else {
|
||||
# update choices
|
||||
old_choices <- filterd_line$choices
|
||||
new_choices <- unique(c(old_choices, value))
|
||||
new_choices <- new_choices[!is.na(new_choices)]
|
||||
|
||||
shiny::updateRadioButtons(inputId = form_id, selected = value, choices = new_choices)
|
||||
}
|
||||
}
|
||||
|
||||
# checkboxes
|
||||
if (form_type == "checkbox" && !is.na(value)) {
|
||||
vars <- stringr::str_split_1(value, local_delimeter)
|
||||
shiny::updateCheckboxGroupInput(inputId = form_id, selected = vars)
|
||||
}
|
||||
if (form_type == "checkbox" && is.na(value)) {
|
||||
shiny::updateCheckboxGroupInput(inputId = form_id, selected = character(0))
|
||||
if (form_type == "checkbox") {
|
||||
|
||||
if (is_this_empty_value(value)) {
|
||||
shiny::updateCheckboxGroupInput(inputId = form_id, selected = character(0))
|
||||
} else {
|
||||
|
||||
vars <- stringr::str_split_1(value, local_delimeter)
|
||||
|
||||
# update choices
|
||||
old_choices <- filterd_line$choices
|
||||
new_choices <- unique(c(old_choices, vars))
|
||||
new_choices <- new_choices[!is.na(new_choices)]
|
||||
|
||||
shiny::updateCheckboxGroupInput(inputId = form_id, selected = vars, choices = new_choices)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# if (type == "inline_table") {
|
||||
# message("EMPTY")
|
||||
# }
|
||||
}
|
||||
|
||||
#' @export
|
||||
@@ -361,7 +377,7 @@ clean_forms = function(
|
||||
form_id = x_id,
|
||||
form_type = x_type,
|
||||
value = get_empty_data(x_type),
|
||||
scheme = schm$get_schema(table_name),
|
||||
scheme = schm$get_scheme(table_name),
|
||||
ns = ns
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user