Merge branch 'main' of https://gitea.madelirihs.ru/madeliri/shiny_form
This commit is contained in:
20
.Rprofile
20
.Rprofile
@@ -1 +1,21 @@
|
||||
source("renv/activate.R")
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
paths <- c(
|
||||
"FORM_AUTH_ENABLED",
|
||||
"FORM_VERSION",
|
||||
"FORM_TITLE"
|
||||
)
|
||||
|
||||
lines <- paths[Sys.getenv(paths) == ""]
|
||||
|
||||
if (length(lines) > 0) {
|
||||
cli::cli_h3("Настройка путей окружения")
|
||||
cli::cli_code(paste0(lines, "="))
|
||||
cli::cli_inform(c(
|
||||
"i" = "Для нормальной работы скриптов добавьте в {.file .Renviron}:"
|
||||
))
|
||||
}
|
||||
})()
|
||||
|
||||
25
app.R
25
app.R
@@ -118,9 +118,9 @@ server <- function(input, output, session) {
|
||||
if (AUTH_ENABLED) {
|
||||
reactiveValuesToList(res_auth)
|
||||
if (res_auth$admin) {
|
||||
print("admin")
|
||||
# print("admin")
|
||||
} else {
|
||||
print("not_admin")
|
||||
# print("not_admin")
|
||||
showing_buttons <- FALSE
|
||||
}
|
||||
}
|
||||
@@ -234,8 +234,8 @@ server <- function(input, output, session) {
|
||||
) {
|
||||
|
||||
nested_key_id <- mhcs()$get_key_id(table_name)
|
||||
input_types <- unname(id_and_types_list)
|
||||
input_ids <- names(id_and_types_list)
|
||||
input_types <- unname(id_and_types_list)
|
||||
input_ids <- names(id_and_types_list)
|
||||
|
||||
if (missing(ns)) ns <- NULL
|
||||
|
||||
@@ -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(""); }'))
|
||||
@@ -589,6 +594,8 @@ server <- function(input, output, session) {
|
||||
mhcs(),
|
||||
ns = NS(values$nested_form_id)
|
||||
)
|
||||
} else {
|
||||
utils$clean_forms(values$nested_form_id, mhcs(), NS(values$nested_form_id))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1138,7 +1145,7 @@ server <- function(input, output, session) {
|
||||
append = TRUE
|
||||
)
|
||||
|
||||
message <- glue::glue("Данные таблицы '{table_name}' успешно обновлены")
|
||||
message <- glue::glue("Данные таблицы '{table_name}' успешно обновлены (добавлено {nrow(df)} записей)")
|
||||
showNotification(
|
||||
message,
|
||||
type = "message"
|
||||
|
||||
Binary file not shown.
@@ -5,7 +5,7 @@ set_global_options = function(
|
||||
APP.DEBUG = FALSE,
|
||||
# APP.FILE_DB = fs::path("data.sqlite"),
|
||||
shiny.host = "127.0.0.1",
|
||||
shiny.port = 1337,
|
||||
shiny.port = 1338,
|
||||
...
|
||||
) {
|
||||
options(
|
||||
|
||||
@@ -22,6 +22,10 @@ scheme_R6 <- R6::R6Class(
|
||||
check <- private$reserved_table_names %in% private$nested_forms_names
|
||||
if (any(check)) cli::cli_abort(c("нельзя использовать данные имена вложенных таблиц:", paste("- ", private$reserved_table_names[check])))
|
||||
|
||||
# проверка на длину строк
|
||||
check <- (nchar(private$nested_forms_names) > 31)
|
||||
if (any(check)) cli::cli_abort(c("нельзя использовать имена длиной более 31 символа:", paste("- ", private$nested_forms_names[check])))
|
||||
|
||||
purrr::walk(
|
||||
.x = purrr::set_names(private$nested_forms_names),
|
||||
.f = \(nested_form_id) {
|
||||
|
||||
@@ -162,7 +162,7 @@ render_forms = function(
|
||||
choices = choices,
|
||||
selected = NULL,
|
||||
options = list(
|
||||
create = FALSE,
|
||||
create = TRUE,
|
||||
onInitialize = I('function() { this.setValue(""); }')
|
||||
)
|
||||
)
|
||||
@@ -177,7 +177,7 @@ render_forms = function(
|
||||
selected = NULL,
|
||||
multiple = TRUE,
|
||||
options = list(
|
||||
create = FALSE,
|
||||
create = TRUE,
|
||||
onInitialize = I('function() { this.setValue(""); }')
|
||||
)
|
||||
)
|
||||
@@ -263,7 +263,8 @@ update_forms_with_data = function(
|
||||
local_delimeter = getOption("SYMBOL_DELIM"),
|
||||
ns
|
||||
) {
|
||||
|
||||
|
||||
options(box.path = here::here())
|
||||
box::use(modules/data_manipulations[is_this_empty_value])
|
||||
|
||||
# print("-----------------")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# SETUP AUTH =============================
|
||||
# Init DB using credentials data
|
||||
credentials <- data.frame(
|
||||
user = c("admin", "user"),
|
||||
user = c("admin", "user"),
|
||||
password = c("admin", "user"),
|
||||
# password will automatically be hashed
|
||||
admin = c(TRUE, FALSE),
|
||||
|
||||
Reference in New Issue
Block a user