feat: задачи - в отдельном модуле
This commit is contained in:
39
app/forms.R
Normal file
39
app/forms.R
Normal file
@@ -0,0 +1,39 @@
|
||||
options(box.path = here::here())
|
||||
box::use(
|
||||
modules/utils,
|
||||
)
|
||||
|
||||
|
||||
#' @export
|
||||
load_data_to_form <- function(
|
||||
df,
|
||||
table_name = "main",
|
||||
mhcs,
|
||||
ns
|
||||
) {
|
||||
|
||||
input_types <- unname(mhcs()$get_id_type_list(table_name))
|
||||
input_ids <- names(mhcs()$get_id_type_list(table_name))
|
||||
if (missing(ns)) ns <- NULL
|
||||
|
||||
# transform df to list
|
||||
# loaded_df_for_id <- as.list(df)
|
||||
# loaded_df_for_id <- df[input_ids]
|
||||
|
||||
# rewrite input forms
|
||||
purrr::walk2(
|
||||
.x = input_types,
|
||||
.y = input_ids,
|
||||
.f = \(x_type, x_id) {
|
||||
|
||||
# updating forms with loaded data
|
||||
utils$update_forms_with_data(
|
||||
form_id = x_id,
|
||||
form_type = x_type,
|
||||
value = df[[x_id]],
|
||||
scheme = mhcs()$get_scheme(table_name),
|
||||
ns = ns
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user