fix: корректное отображение столбцов во вложенной форме

This commit is contained in:
2026-04-13 18:01:17 +03:00
parent 5a6dba25ee
commit 4c3d339361

33
app.R
View File

@@ -362,8 +362,8 @@ server <- function(input, output, session) {
} }
# nested ui # nested ui
if (!is.null(values$nested_key)) { nested_form_panels <- if (!is.null(values$nested_key)) {
yay_its_fun <- purrr::map( purrr::map(
.x = unique(this_nested_form_scheme$subgroup), .x = unique(this_nested_form_scheme$subgroup),
.f = \(subgroup) { .f = \(subgroup) {
@@ -383,9 +383,8 @@ server <- function(input, output, session) {
} }
) )
} else { } else {
yay_its_fun <- list(bslib::nav_panel("", "empty")) list(bslib::nav_panel("", div("Нет доступных записей.", br(), "Необходимо создать новую запись.")))
} }
# yay_its_fun <- !!!yay_its_fun
# ui для всплывающего окна # ui для всплывающего окна
ui_for_inline_table <- navset_card_underline( ui_for_inline_table <- navset_card_underline(
@@ -393,19 +392,18 @@ server <- function(input, output, session) {
width = 300, width = 300,
selectizeInput( selectizeInput(
inputId = "nested_key_selector", inputId = "nested_key_selector",
label = this_nested_form_key_scheme$form_label, label = strong(this_nested_form_key_scheme$form_label),
choices = kyes_for_this_table, choices = kyes_for_this_table,
selected = values$nested_key, selected = values$nested_key,
# options = list(placeholder = "действие комиссии", create = FALSE, onInitialize = I('function() { this.setValue(""); }')) # options = list(placeholder = "действие комиссии", create = FALSE, onInitialize = I('function() { this.setValue(""); }'))
), ),
actionButton("add_new_nested_key_button", "add"), actionButton("add_new_nested_key_button", "Добавить новую запись", icon("plus", lib = "font-awesome")),
actionButton("nested_form_save_button", "save"), actionButton("nested_form_save_button", "Сохранить данные", icon("floppy-disk", lib = "font-awesome")),
actionButton("nested_form_dt_button", "dt"), actionButton("nested_form_dt_button", "DT", icon("table", lib = "font-awesome")),
uiOutput("validation_nested"), uiOutput("validation_nested"),
open = list(mobile = "always-above") open = list(mobile = "always-above")
), ),
# if (!is.null(values$nested_key)) {rlang::syms(!!!yay_its_fun)} else bslib::nav_panel("empty") !!!nested_form_panels
!!!yay_its_fun
) )
# проверка данных для внутренних таблиц # проверка данных для внутренних таблиц
@@ -433,10 +431,11 @@ server <- function(input, output, session) {
con = con con = con
) )
col_types <- mhcs()$get_schema(values$nested_form_id) |> col_types <- mhcs()$get_schema_with_values_forms(values$nested_form_id) |>
dplyr::distinct(form_id, form_type, form_label) dplyr::distinct(form_id, form_type, form_label)
date_cols <- subset(col_types, form_type == "date", form_id, drop = TRUE)
date_cols <- which(col_types$form_type == "date")
values$data <- values$data |> values$data <- values$data |>
select(-mhcs()$get_main_key_id) |> select(-mhcs()$get_main_key_id) |>
@@ -450,7 +449,7 @@ server <- function(input, output, session) {
values$data, values$data,
caption = 'Table 1: This is a simple caption for the table.', caption = 'Table 1: This is a simple caption for the table.',
rownames = FALSE, rownames = FALSE,
# colnames = dplyr::pull(col_types, form_id, form_label), colnames = col_types |> dplyr::pull(form_id, form_label),
extensions = c('KeyTable', "FixedColumns"), extensions = c('KeyTable', "FixedColumns"),
editable = 'cell', editable = 'cell',
selection = "none", selection = "none",
@@ -876,7 +875,9 @@ server <- function(input, output, session) {
dplyr::across(tidyselect::all_of({{date_columns}}), as.Date), dplyr::across(tidyselect::all_of({{date_columns}}), as.Date),
# числа - к единому формату десятичных значений # числа - к единому формату десятичных значений
dplyr::across(tidyselect::all_of({{number_columns}}), ~ gsub("\\.", "," , .x)), dplyr::across(tidyselect::all_of({{number_columns}}), ~ gsub("\\.", "," , .x)),
) ) |>
# очистка от пустых ключей
dplyr::filter(!is.na(main_key))
df df
} }
@@ -1111,6 +1112,10 @@ server <- function(input, output, session) {
} }
# очистка от пустых ключей
df <- df |>
dplyr::filter(!is.na(main_key))
DBI::dbWriteTable( DBI::dbWriteTable(
con, con,
name = table_name, name = table_name,