Skip to content

Commit

Permalink
prepared CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Jun 7, 2022
1 parent ea86ffb commit 8885bb4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: jsTreeR
Type: Package
Title: A Wrapper of the JavaScript Library 'jsTree'
Version: 1.6.0.9001
Version: 2.0.0
Authors@R: c(
person("Stéphane", "Laurent", email = "[email protected]", role = c("aut", "cre")),
person("jQuery contributors", role = c("ctb", "cph"), comment = "jQuery"),
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# jsTreeR 1.6.0.9001 (2022-05-28)
# jsTreeR 2.0.0 (2022-06-08)

- The package now provides the 'tree navigator' Shiny module, which allows to
render a files and folders navigator in the server side file system.

- New Shiny input value accessible in `input$ID_selected_tree`. This is like
`input$ID_selected` but it also provides the ascendants of the selected nodes.

- Upgraded 'jsTree' to the development version.
- Upgraded 'jsTree' library to the development version.


# jsTreeR 1.6.0 (2022-02-28)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/stla/jsTreeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/stla/jsTreeR/actions/workflows/R-CMD-check.yaml)
[![](https://www.r-pkg.org/badges/version/jsTreeR?color=orange)](https://cran.r-project.org/package=jsTreeR)
[![](https://img.shields.io/badge/devel%20version-1.6.0.9001-blue.svg)](https://github.com/stla/jsTreeR)
[![](https://img.shields.io/badge/devel%20version-2.0.0-blue.svg)](https://github.com/stla/jsTreeR)
<!-- badges: end -->

A wrapper of the JavaScript library [jsTree](https://www.jstree.com/).
Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Test environments

* Windows 10, R 4.1.2
* Windows 10, R 4.2.0
* win-builder (devel)
* mac-builder
* Ubuntu 20, via Github action
Expand Down
76 changes: 76 additions & 0 deletions inst/essais/essai_curiousJorge.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
library(jsTreeR)

nodes <- list(
list(
text = "Menu",
state = list(opened = TRUE),
children = list(
list(
text = "A",
type = "moveable",
state = list(disabled = TRUE)
),
list(
text = "B",
type = "moveable",
state = list(disabled = TRUE)
),
list(
text = "C",
type = "moveable",
state = list(disabled = TRUE)
),
list(
text = "D",
type = "moveable",
state = list(disabled = TRUE)
)
)
),
list(
text = "Drag here:",
type = "target",
state = list(opened = TRUE)
)
)

checkCallback <- JS(
"function(operation, node, parent, position, more) { console.log(node);",
" if(operation === 'copy_node') {",
" if(parent.id === '#' || node.parent !== 'j1_1' || parent.type !== 'target') {",
" return false;", # prevent moving an item above or below the root
" }", # and moving inside an item except a 'target' item
" }",
" return true;", # allow everything else
"}"
)

dnd <- list(
always_copy = TRUE,
is_draggable = JS(
"function(node) {",
" return node[0].type === 'moveable';",
"}"
)
)

customMenu <- JS(
"function customMenu(node) {",
" var tree = $('#mytree').jstree(true);", # 'mytree' is the Shiny id or the elementId
" var items = {",
" 'delete' : {",
" 'label' : 'Delete',",
" 'action' : function (obj) { tree.delete_node(node); },",
" 'icon' : 'glyphicon glyphicon-trash'",
" }",
" }",
" return items;",
"}")


jstree(
nodes, dragAndDrop = TRUE, dnd = dnd, checkCallback = checkCallback,
types = list(moveable = list(), target = list()),
contextMenu = list(items = customMenu),
elementId = "mytree" # don't use elementId in Shiny! use the Shiny id
)

0 comments on commit 8885bb4

Please sign in to comment.