Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/deploy-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Workflow derived from https://github.com/posit-dev/r-shinylive/blob/main/.github/workflows/deploy-app.yaml
name: deploy to gh-pages

on:
workflow_call:
inputs:
cache-version:
type: string
default: "1"
required: false
push:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: rstudio/shiny-workflows/setup-r-package@v1
with:
packages: |
renv
posit-dev/r-shinylive
sessioninfo
cache-version: ${{ github.event.inputs.cache-version }}

- name: Find package dependencies
shell: Rscript {0}
id: packages
run: |
# Find package dependencies using {renv} and install with {pak}
pak::pak(
unique(renv::dependencies("./editbl")$Package)
)

- name: Build site
shell: Rscript {0}
run: |
shinylive::export("./demo", "site")

- name: Upload site artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
with:
path: "site"

deploy:
if: github.ref == 'refs/heads/main'
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/editbl.Rcheck/
editbl_*.tar.gz



.site
.Rbuildignore
50 changes: 50 additions & 0 deletions demo/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
library(shiny)
library(editbl)

ui <- fluidPage(
tags$h1('editbl - demo'),
br(),
editbl::eDTOutput('data'),
verbatimTextOutput('modifiedData'),
helpText('Note different behavior of different data types.'),
helpText('Edit cells by clicking the in-row buttons or directly within the table.'),
helpText("See how 'id' is generated on the fly."),
helpText("Note how only 'city_id' is stored even if not displayed. Cities are a separate table with foreign key."),
)

server <- function(input,output,session){
superheroes <- data.frame(
id = sapply(1:3, uuid::UUIDgenerate),
first_name = c('Bruce', 'Tony', 'Clark'),
last_name = c('Wayne', 'Stark', 'Kent'),
first_appearance = as.Date(c('1939-03-30', '1962-03-15', '1938-04-18')),
publisher = as.factor(c('DC Comics', 'Marvel', 'DC Comics')),
cars_owned = c(5,17,1),
city_id = c(1,2,3)
)

cities <- data.frame(
city_id = c(1,2,3),
name = c('New York', 'Gotham City', 'Smallville'),
country = c('US', 'US', 'US')
)


modifiedData <- editbl::eDT(
id = 'data',
data = superheroes,
foreignTbls = list(foreignTbl(superheroes, cities, 'city_id')),
options = list(columnDefs = list(list(visible=FALSE, targets=c("id","city_id")))),
defaults = dplyr::tibble(id = uuid::UUIDgenerate())
)

output$modifiedData <- renderPrint({
data <- modifiedData$state()
print(str(data))
print(data)
}
)

}
shiny::shinyApp(ui,server)

Loading