From f344859f9214e6d71e17d2c10fdb7ffebe235832 Mon Sep 17 00:00:00 2001 From: drdolgovvv Date: Wed, 15 Apr 2026 15:02:33 +0300 Subject: [PATCH] fix: nested forms for select_one and et cetera --- app.R | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app.R b/app.R index c3c655f..d272b41 100644 --- a/app.R +++ b/app.R @@ -342,8 +342,13 @@ server <- function(input, output, session) { this_nested_form_scheme <- mhcs()$get_scheme(values$nested_form_id) # мини-схема для ключа - this_nested_form_key_scheme <- subset(this_nested_form_scheme, form_id == key_id) - if (nrow(this_nested_form_key_scheme) > 1) cli::cli_abort("количество строк не может быть больше одного для ключа") + this_nested_form_key_scheme <- this_nested_form_scheme |> + dplyr::filter(form_id == {{key_id}}) + + this_nested_form_key_scheme_smoll <- this_nested_form_key_scheme |> + dplyr::distinct(form_id, form_label, form_type) + + if (nrow(this_nested_form_key_scheme_smoll) > 1) cli::cli_abort("количество строк не может быть больше одного для ключа") # выбираем все ключи из баз данных kyes_for_this_table <- db$get_nested_keys_from_table(values$nested_form_id, mhcs(), values$main_key, con) @@ -352,7 +357,7 @@ server <- function(input, output, session) { values$nested_key <- if (length(kyes_for_this_table) == 0) NULL else kyes_for_this_table[[1]] # если ключ в формате даты - дать человекочитаемые данные - if (this_nested_form_key_scheme$form_type == "date") { + if (this_nested_form_key_scheme_smoll$form_type == "date") { kyes_for_this_table <- setNames( kyes_for_this_table, format(as.Date(kyes_for_this_table), "%d.%m.%Y") @@ -390,7 +395,7 @@ server <- function(input, output, session) { width = 300, selectizeInput( inputId = "nested_key_selector", - label = strong(this_nested_form_key_scheme$form_label), + label = strong(this_nested_form_key_scheme_smoll$form_label), choices = kyes_for_this_table, selected = values$nested_key, # options = list(placeholder = "действие комиссии", create = FALSE, onInitialize = I('function() { this.setValue(""); }'))