diff --git a/app.R b/app.R index a5bd6a4..edf7a6d 100644 --- a/app.R +++ b/app.R @@ -703,7 +703,9 @@ server <- function(input, output, session) { # ========================================= # MAIN BUTTONS LOGIC ====================== # ========================================= + ## добавить новый главный ключ ------------------------ + ### modal ------- observeEvent(input$add_new_main_key_button, { # данные для главного ключа @@ -729,7 +731,7 @@ server <- function(input, output, session) { }) - ## действие при подтверждении (проверка нового создаваемого ключа) ------- + ### подтверждение(проверка нового создаваемого ключа) ------- observeEvent(input$confirm_create_new_main_key, { req(input[[mhcs()$get_main_key_id]]) @@ -737,7 +739,6 @@ server <- function(input, output, session) { on.exit(db$close_db_connection(con, "confirm_create_new_key"), add = TRUE) new_main_key <- trimws(input[[mhcs()$get_main_key_id]]) - existed_key <- db$get_keys_from_table("main", mhcs(), con) # если введенный ключ уже есть в базе @@ -751,12 +752,11 @@ server <- function(input, output, session) { values$main_key <- new_main_key log_action_to_db("creating new key", values$main_key, con) - removeModal() }) - ## очистка всех полей ----------------------- - # show modal on click of button + ## переход на главный акран ----------------------- + ### show modal ------- observeEvent(input$clean_data_button, { showModal(modalDialog( "Данное действие очистит все заполненные данные. Убедитесь, что нужные данные сохранены.", @@ -769,7 +769,7 @@ server <- function(input, output, session) { )) }) - # when action confirm - perform action + ### when action confirm - perform action --- observeEvent(input$clean_all_action, { # rewrite all inputs with empty data @@ -802,7 +802,8 @@ server <- function(input, output, session) { ) }) - ## список ключей для загрузки данных ------------------- + ## загрузка данных ------------------- + ### modal with keys ----- observeEvent(input$load_data_button, { con <- db$make_db_connection(scheme(),"load_data_button") @@ -845,7 +846,7 @@ server <- function(input, output, session) { ) }) - ## загрузка данных по главному ключу ------------------ + ### confirm ------------------ observeEvent(input$load_data, { req(input$load_data_key_selector) @@ -853,15 +854,14 @@ server <- function(input, output, session) { }) + ## логика: смена ключа ------- observeEvent(values$main_key, { req(values$main_key) - print(values$main_key) - con <- db$make_db_connection(scheme(),"load_data") on.exit(db$close_db_connection(con, "load_data"), add = TRUE) - existed_main_keys <- (db$get_keys_from_table("main", mhcs(), con)) + existed_main_keys <- db$get_keys_from_table("main", mhcs(), con) if (values$main_key %in% existed_main_keys) { @@ -881,14 +881,15 @@ server <- function(input, output, session) { log_action_to_db("loading data", values$main_key, con = con) } else { + utils$clean_forms("main", mhcs()) + } - main_form_is_empty(FALSE) - # обновление счетичка задач tasks$update_task_button_count(con, values, NS("tasks")) + main_form_is_empty(FALSE) removeModal() }) @@ -936,7 +937,7 @@ server <- function(input, output, session) { # добавить мета информацию list_of_df[["meta"]] <- dplyr::tribble( ~`Параметр` , ~`Значение`, - "Пользователь" , ifelse(AUTH_ENABLED, res_auth$user, "anonymous"), + "Пользователь" , values$current_user, "Название базы" , names(enabled_schemes)[enabled_schemes == scheme()], "id базы" , scheme(), "id формы" , config::get("form_id"), @@ -1057,6 +1058,7 @@ server <- function(input, output, session) { ) ## import data from xlsx ---------------------- + ### modal ----- observeEvent(input$button_upload_data_from_xlsx, { showModal(modalDialog( @@ -1080,6 +1082,7 @@ server <- function(input, output, session) { }) + ### confirm -------- observeEvent(input$button_upload_data_from_xlsx_confirm, { req(input$upload_xlsx) @@ -1238,7 +1241,7 @@ server <- function(input, output, session) { action_row <- tibble( date = Sys.time(), - user = ifelse(AUTH_ENABLED, res_auth$user, "anonymous"), + user = values$current_user, app_id = config::get("form_id"), app_ver = config::get("form_app_version"), remote_addr = session$request$REMOTE_ADDR,