addEdit: Add database entry button: server function

Description Usage Arguments Value See Also

View source: R/addEditModules.R

Description

This function and addEditUI are used in conjection to add the UI and server elements necessary to add a row to a given table in a database

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
addEdit(
  input,
  output,
  session,
  addTitle,
  editTitle,
  modalUI,
  inputData,
  reactiveData,
  staticChoices = NULL,
  checkDuplicate = NULL,
  db,
  dbTable,
  dtRow
)

Arguments

input, output, session

These parameters are handled by callModule and can be ignored.

addTitle

Title to display at the top of the add Modal

editTitle

Title to display at the top of the edit Modal

modalUI

Function that creates the modal UI.

inputData

a data.frame containing columns ids, labels, type, choicesTable, choicesValues, choicesLabels which correspond to

ids

The field names in the database. These ids will also be used as the inputId for shiny inputs.

labels

These are character values which will be used as the label for shiny inputs and be displayed above the input in the UI.

type

The type of shiny input to be used.

choicesTable, choicesValues, choicesLabels

Only used if the desired input has predefined choices (selectInput/selectizeInput). If neither of these inputs are used, then the values should be NA. If one of these inputs is used then:

choicesTable

Is the table in the database where the choices for the given input are.

choicesValues

Is the column in the table which stores the numeric identifier for the choice

choicesLabels

Is the column in the table which stores the character name for the choices

reactiveData

Reactive which stores all of the tables from the database as seperate data.frames

staticChoices

list where choices for static selectize inputs are defined.

checkDuplicate

character vector specifing which fields to check for possible duplication. Default value is null, and no fields are checked for duplicates

db

a DBIConnection object, as returned by dbConnect. In other words, the object the database connection is saved to.

dbTable

The database table the new data will be added to.

dtRow

Reactive which stores the row selected in the datatable

Value

Shiny observeEvent's which control actions when the add button is pressed, as well as the save button in the modal.

See Also

addEditUI


JamesCuster/CARTMod documentation built on March 8, 2020, 5:57 a.m.