feat: вызов DT актуальный задач + переход к ID из общего списка
This commit is contained in:
80
app.R
80
app.R
@@ -21,6 +21,7 @@ box::use(
|
||||
|
||||
global_options$set_global_options(
|
||||
shiny.host = "0.0.0.0"
|
||||
# APP.DEBUG = TRUE
|
||||
)
|
||||
global_options$check_and_init_scheme()
|
||||
|
||||
@@ -159,6 +160,31 @@ server <- function(input, output, session) {
|
||||
}
|
||||
})
|
||||
|
||||
output$base_data <- renderUI({
|
||||
|
||||
con <- db$make_db_connection(scheme(),"base_data")
|
||||
on.exit(db$close_db_connection(con, "base_data"), add = TRUE)
|
||||
|
||||
# записей в базе всего
|
||||
query <- glue::glue("SELECT COUNT ({mhcs()$get_main_key_id}) FROM main")
|
||||
records_count <- DBI::dbGetQuery(con, query) |>
|
||||
dplyr::pull()
|
||||
|
||||
# задачи на сегодня
|
||||
if ("tasks" %in% DBI::dbListTables(con)) {
|
||||
query <- glue::glue("SELECT COUNT (task_id) FROM tasks WHERE task_status = 'active'")
|
||||
tasks_count <- DBI::dbGetQuery(con, query) |>
|
||||
dplyr::pull()
|
||||
} else {
|
||||
tasks_count <- 0
|
||||
}
|
||||
|
||||
div(
|
||||
strong("Записей всего:"), records_count, br(),
|
||||
if (tasks_count > 0) p(strong("Задач на сегодня:"), actionLink("tasks-show_dt_today", tasks_count)) else "Задач нет"
|
||||
)
|
||||
})
|
||||
|
||||
# REACTIVE VALUES =================================
|
||||
# Create a reactive values object to store the input data
|
||||
values <- reactiveValues(
|
||||
@@ -193,9 +219,9 @@ server <- function(input, output, session) {
|
||||
choices = enabled_schemes,
|
||||
selected = scheme()
|
||||
),
|
||||
uiOutput("base_data"),
|
||||
"Для начала работы нужно создать новую запись или загрузить существующую!",
|
||||
# сво
|
||||
strong("tasks"),
|
||||
# загрузка панели для работы с базой данных
|
||||
uiOutput("admin_buttons_panel")
|
||||
)
|
||||
@@ -205,6 +231,7 @@ server <- function(input, output, session) {
|
||||
validator_main(data_validation$init_val(mhcs()$get_scheme("main")))
|
||||
validator_main()$enable()
|
||||
mhcs()$get_main_form_ui
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -721,11 +748,9 @@ server <- function(input, output, session) {
|
||||
)
|
||||
return()
|
||||
}
|
||||
|
||||
|
||||
values$main_key <- new_main_key
|
||||
main_form_is_empty(FALSE)
|
||||
log_action_to_db("creating new key", values$main_key, con)
|
||||
utils$clean_forms("main", mhcs())
|
||||
|
||||
removeModal()
|
||||
})
|
||||
@@ -754,6 +779,7 @@ server <- function(input, output, session) {
|
||||
|
||||
removeModal()
|
||||
showNotification("Данные очищены!", type = "warning")
|
||||
|
||||
})
|
||||
|
||||
## сохранение даннных -------------------------------
|
||||
@@ -823,29 +849,46 @@ server <- function(input, output, session) {
|
||||
observeEvent(input$load_data, {
|
||||
req(input$load_data_key_selector)
|
||||
|
||||
values$main_key <- input$load_data_key_selector
|
||||
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
df <- db$read_df_from_db_by_id(
|
||||
table_name = "main",
|
||||
schm = mhcs(),
|
||||
main_key_value = input$load_data_key_selector,
|
||||
con = con
|
||||
)
|
||||
existed_main_keys <- (db$get_keys_from_table("main", mhcs(), con))
|
||||
|
||||
forms$load_data_to_form(
|
||||
df = df,
|
||||
table_name = "main",
|
||||
mhcs
|
||||
)
|
||||
|
||||
values$main_key <- input$load_data_key_selector
|
||||
if (values$main_key %in% existed_main_keys) {
|
||||
|
||||
df <- db$read_df_from_db_by_id(
|
||||
table_name = "main",
|
||||
schm = mhcs(),
|
||||
main_key_value = values$main_key,
|
||||
con = con
|
||||
)
|
||||
|
||||
forms$load_data_to_form(
|
||||
df = df,
|
||||
table_name = "main",
|
||||
mhcs
|
||||
)
|
||||
|
||||
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"))
|
||||
|
||||
log_action_to_db("loading data", values$main_key, con = con)
|
||||
removeModal()
|
||||
|
||||
})
|
||||
@@ -1209,7 +1252,6 @@ server <- function(input, output, session) {
|
||||
# TASKS ---------------------------------------
|
||||
tasks$server("tasks", values, scheme, mhcs)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user