0.14.1 go
This commit is contained in:
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/renv
|
||||
|
||||
.Renviron
|
||||
.DS_Store
|
||||
.lintr
|
||||
|
||||
*.sqlite
|
||||
*.tar
|
||||
68
CHANGELOG.md
Normal file
68
CHANGELOG.md
Normal file
@@ -0,0 +1,68 @@
|
||||
### 0.??.?
|
||||
|
||||
##### features
|
||||
- added checkboxes input form;
|
||||
- added button to reset data in forms;
|
||||
- added option to export input data to `.docx` format (using `rmarkdown`), using `reference.docx` template;
|
||||
- added new column in `main.xlsx` schema with `required` option: now you can set specifically which forms is required (1 - is required, NA - is not required) - this option now used in input validation (doesn't block saving data yet);
|
||||
- checking on load if schema changed (comparing to existing db):
|
||||
- if new input form added in schema - adding it also on database (with empty values);
|
||||
- if input form deleted - stop app to prevent data loss;
|
||||
- if input form was renamed - stop app to prevent data loss;
|
||||
- in other cases - show warnings;
|
||||
|
||||
##### fixes
|
||||
|
||||
- fixed not erasing inputs while loading empty values (with checkboxes, radiobuttons);
|
||||
- +number input validation
|
||||
|
||||
##### changes
|
||||
|
||||
- some code refactoring;
|
||||
- replacing NumberImput to TextInput due to correct implement validation;
|
||||
|
||||
|
||||
|
||||
### 0.14.1 2024-10-14
|
||||
|
||||
##### fixes
|
||||
|
||||
- catching crash file due to bug in rhandsometable (fail to export tables with empty rows)
|
||||
|
||||
|
||||
|
||||
### 0.14 2024-10-14
|
||||
|
||||
##### changes
|
||||
|
||||
- code rafactoring
|
||||
- add visual data validation
|
||||
|
||||
|
||||
|
||||
### 0.13 2024-10-11
|
||||
|
||||
##### changes
|
||||
|
||||
- moving script to init login db to separate file
|
||||
- wider inline tables
|
||||
|
||||
|
||||
|
||||
### 0.12 2024-09-29
|
||||
|
||||
##### fixes:
|
||||
|
||||
- error while saving tables to db due to wrong data formats
|
||||
|
||||
##### changes:
|
||||
|
||||
- moving config.yml to configs folder
|
||||
- moving schemas to configs folder
|
||||
|
||||
|
||||
### 0.11 2024-09-23
|
||||
|
||||
##### fixes:
|
||||
- error while loading table due to change PostrgreSQL driver
|
||||
- error while export db as .xlsx due to misspelling in button name
|
||||
17
LICENSE
Normal file
17
LICENSE
Normal file
@@ -0,0 +1,17 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2025 @madeliri
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====================================
|
||||
|
||||
Данная лицензия разрешает лицам, получившим копию данного программного обеспечения и сопутствующей документации (далее — Программное обеспечение), безвозмездно использовать Программное обеспечение без ограничений, включая неограниченное право на использование, копирование, изменение, слияние, публикацию, распространение, сублицензирование и/или продажу копий Программного обеспечения, а также лицам, которым предоставляется данное Программное обеспечение, при соблюдении следующих условий:
|
||||
|
||||
Указанное выше уведомление об авторском праве и данные условия должны быть включены во все копии или значимые части данного Программного обеспечения.
|
||||
|
||||
ДАННОЕ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ «КАК ЕСТЬ», БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, ЯВНО ВЫРАЖЕННЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ ГАРАНТИИ ТОВАРНОЙ ПРИГОДНОСТИ, СООТВЕТСТВИЯ ПО ЕГО КОНКРЕТНОМУ НАЗНАЧЕНИЮ И ОТСУТСТВИЯ НАРУШЕНИЙ, НО НЕ ОГРАНИЧИВАЯСЬ ИМИ. НИ В КАКОМ СЛУЧАЕ АВТОРЫ ИЛИ ПРАВООБЛАДАТЕЛИ НЕ НЕСУТ ОТВЕТСТВЕННОСТИ ПО КАКИМ-ЛИБО ИСКАМ, ЗА УЩЕРБ ИЛИ ПО ИНЫМ ТРЕБОВАНИЯМ, В ТОМ ЧИСЛЕ, ПРИ ДЕЙСТВИИ КОНТРАКТА, ДЕЛИКТЕ ИЛИ ИНОЙ СИТУАЦИИ, ВОЗНИКШИМ ИЗ-ЗА ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ИЛИ ИНЫХ ДЕЙСТВИЙ С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ.
|
||||
34
README.md
Normal file
34
README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# not ready yet
|
||||
|
||||
# О репозитории
|
||||
|
||||
Данный проект представляет собой shiny-приложение (написанное на языке програмирования R), для заполнения каких-то данных и последующим экспортом в `.xlsx` формат.
|
||||
|
||||
Структура формы (соответственно и базы) задается на осно
|
||||
|
||||
Данные хранятся в базе данных `SQLite` (так же возможно использование `PostgreSQL`).
|
||||
|
||||
# Зачем?
|
||||
|
||||
...
|
||||
|
||||
|
||||
# структура main.xlsx
|
||||
|
||||
Файл, формирующий структуру всей форму, представляет собой таблицу в формате `.xlsx`, состоящий из следующих столбцов:
|
||||
|
||||
- `part` - группировка первого уровня;
|
||||
- `subgroup` - группировка второго уровня (наименование колонок);
|
||||
- `form_id` - id;
|
||||
- `form_label` - Название формы;
|
||||
- `form_type` - тип формы, в настоящее время доступные следующие варианты:
|
||||
- `text` - простой текст;
|
||||
- `date` - дата;
|
||||
- `select_one` - выбор одного варианта (выпадающий список);
|
||||
- `select_multiple` - выбор нескольких вариантов (выпадающий список);
|
||||
- `number` - число;
|
||||
- `radio` - выбор одного варианта (radio buttons);
|
||||
- `description` - описание (отображение текста, без формы выбора/ввода);
|
||||
- `inline_table` - вложенная таблица (rhandsometables);
|
||||
- `choices` - варианты выбора (если предполагаются типом формы ввода);
|
||||
- `condition` - условие, при котором форма ввода будет отображаться;
|
||||
6
configs/config.yml
Normal file
6
configs/config.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
default:
|
||||
header: "TEST"
|
||||
version: "0.14.1"
|
||||
# shiny serve option
|
||||
shiny_host: "127.0.0.1"
|
||||
shiny_port: 1337
|
||||
BIN
configs/schemas/example_inline.xlsx
Normal file
BIN
configs/schemas/example_inline.xlsx
Normal file
Binary file not shown.
BIN
configs/schemas/main.xlsx
Normal file
BIN
configs/schemas/main.xlsx
Normal file
Binary file not shown.
106
helpers/functions.R
Normal file
106
helpers/functions.R
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
get_dummy_data <- function(type) {
|
||||
if (type %in% c("text", "select_one", "select_multiple")) return("dummy")
|
||||
if (type %in% c("radio", "checkbox")) return("dummy")
|
||||
if (type %in% c("date")) return(as.Date("1990-01-01"))
|
||||
if (type %in% c("number")) return(as.double(999))
|
||||
}
|
||||
|
||||
get_empty_data <- function(type) {
|
||||
if (type %in% c("text", "select_one", "select_multiple")) return(as.character(NA))
|
||||
if (type %in% c("radio", "checkbox")) return(as.character(NA))
|
||||
if (type %in% c("date")) return(as.Date(NA))
|
||||
if (type %in% c("number")) return(as.character(NA))
|
||||
}
|
||||
|
||||
get_dummy_df <- function() {
|
||||
purrr::map(
|
||||
.x = inputs_simple_list,
|
||||
.f = get_empty_data
|
||||
) %>%
|
||||
as_tibble()
|
||||
}
|
||||
|
||||
|
||||
#' @description Function check if variable contains some sort of empty data
|
||||
#' (NULL, NA, "", other 0-length data) and return `TRUE` (`FALSE` if data is
|
||||
#' not 'empty').
|
||||
#'
|
||||
#' Needed for proper data validation.
|
||||
check_for_empty_data <- function(value_to_check) {
|
||||
# for any 0-length
|
||||
if (length(value_to_check) == 0) return(TRUE)
|
||||
|
||||
# for NA
|
||||
if (is.logical(value_to_check) && is.na(value_to_check)) return(TRUE)
|
||||
|
||||
# for NULL
|
||||
if (is.null(value_to_check)) return(TRUE)
|
||||
|
||||
# for non-empty Date (RETURN FALSE)
|
||||
if (inherits(value_to_check, "Date") && length(value_to_check) != 0) return(FALSE)
|
||||
|
||||
# for empty strings (stands before checking non-empty data for avoid mistakes)
|
||||
if (value_to_check == "") return(TRUE)
|
||||
|
||||
FALSE
|
||||
}
|
||||
|
||||
|
||||
#' @description Function update input forms.
|
||||
#' @param id - input form id;
|
||||
#' @param type - type of form;
|
||||
#' @param value - value to update;
|
||||
update_forms_with_data <- function(id, type, value) {
|
||||
if (type == "text") {
|
||||
shiny::updateTextAreaInput(inputId = id, value = value)
|
||||
}
|
||||
|
||||
if (type == "number") {
|
||||
shiny::updateTextAreaInput(inputId = id, value = value)
|
||||
}
|
||||
|
||||
# supress warnings when applying NA or NULL to date input form
|
||||
if (type == "date") {
|
||||
suppressWarnings(
|
||||
shiny::updateDateInput(inputId = id, value = value)
|
||||
)
|
||||
}
|
||||
|
||||
# select_one
|
||||
if (type == "select_one") {
|
||||
shiny::updateSelectizeInput(inputId = id, selected = value)
|
||||
}
|
||||
|
||||
# select_multiple
|
||||
# check if value is not NA and split by delimetr
|
||||
if (type == "select_multiple" && !is.na(value)) {
|
||||
vars <- stringr::str_split_1(value, "; ")
|
||||
shiny::updateSelectizeInput(inputId = id, selected = vars)
|
||||
}
|
||||
# in other case fill with `character(0)` to proper reseting form
|
||||
if (type == "select_multiple" && is.na(value)) {
|
||||
shiny::updateSelectizeInput(inputId = id, selected = character(0))
|
||||
}
|
||||
|
||||
# radio buttons
|
||||
if (type == "radio" && !is.na(value)) {
|
||||
shiny::updateRadioButtons(inputId = id, selected = value)
|
||||
}
|
||||
if (type == "radio" && is.na(value)) {
|
||||
shiny::updateRadioButtons(inputId = id, selected = character(0))
|
||||
}
|
||||
|
||||
# checkboxes
|
||||
if (type == "checkbox" && !is.na(value)) {
|
||||
vars <- stringr::str_split_1(value, "; ")
|
||||
shiny::updateCheckboxGroupInput(inputId = id, selected = vars)
|
||||
}
|
||||
if (type == "checkbox" && is.na(value)) {
|
||||
shiny::updateCheckboxGroupInput(inputId = id, selected = character(0))
|
||||
}
|
||||
|
||||
if (type == "inline_table") {
|
||||
message("EMPTY")
|
||||
}
|
||||
}
|
||||
19
helpers/init_login_db.r
Normal file
19
helpers/init_login_db.r
Normal file
@@ -0,0 +1,19 @@
|
||||
# script to setup authentification database (using shinymanager)
|
||||
|
||||
# SETUP AUTH =============================
|
||||
# Init DB using credentials data
|
||||
credentials <- data.frame(
|
||||
user = c("admin", "user"),
|
||||
password = c("admin", "user"),
|
||||
# password will automatically be hashed
|
||||
admin = c(TRUE, FALSE),
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
|
||||
# Init the database
|
||||
shinymanager::create_db(
|
||||
credentials_data = credentials,
|
||||
sqlite_path = "auth.sqlite", # will be created
|
||||
passphrase = Sys.getenv("AUTH_DB_KEY")
|
||||
# passphrase = "passphrase_wihtout_keyring"
|
||||
)
|
||||
BIN
references/reference.docx
Normal file
BIN
references/reference.docx
Normal file
Binary file not shown.
Reference in New Issue
Block a user