Skip to content

Commit 8885bb4

Browse files
committed
prepared CRAN submission
1 parent ea86ffb commit 8885bb4

File tree

5 files changed

+81
-5
lines changed

5 files changed

+81
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: jsTreeR
22
Type: Package
33
Title: A Wrapper of the JavaScript Library 'jsTree'
4-
Version: 1.6.0.9001
4+
Version: 2.0.0
55
Authors@R: c(
66
person("Stéphane", "Laurent", email = "[email protected]", role = c("aut", "cre")),
77
person("jQuery contributors", role = c("ctb", "cph"), comment = "jQuery"),

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# jsTreeR 1.6.0.9001 (2022-05-28)
1+
# jsTreeR 2.0.0 (2022-06-08)
22

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

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

9-
- Upgraded 'jsTree' to the development version.
9+
- Upgraded 'jsTree' library to the development version.
1010

1111

1212
# jsTreeR 1.6.0 (2022-02-28)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- badges: start -->
44
[![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)
55
[![](https://www.r-pkg.org/badges/version/jsTreeR?color=orange)](https://cran.r-project.org/package=jsTreeR)
6-
[![](https://img.shields.io/badge/devel%20version-1.6.0.9001-blue.svg)](https://github.com/stla/jsTreeR)
6+
[![](https://img.shields.io/badge/devel%20version-2.0.0-blue.svg)](https://github.com/stla/jsTreeR)
77
<!-- badges: end -->
88

99
A wrapper of the JavaScript library [jsTree](https://www.jstree.com/).

cran-comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Test environments
22

3-
* Windows 10, R 4.1.2
3+
* Windows 10, R 4.2.0
44
* win-builder (devel)
55
* mac-builder
66
* Ubuntu 20, via Github action

inst/essais/essai_curiousJorge.R

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
library(jsTreeR)
2+
3+
nodes <- list(
4+
list(
5+
text = "Menu",
6+
state = list(opened = TRUE),
7+
children = list(
8+
list(
9+
text = "A",
10+
type = "moveable",
11+
state = list(disabled = TRUE)
12+
),
13+
list(
14+
text = "B",
15+
type = "moveable",
16+
state = list(disabled = TRUE)
17+
),
18+
list(
19+
text = "C",
20+
type = "moveable",
21+
state = list(disabled = TRUE)
22+
),
23+
list(
24+
text = "D",
25+
type = "moveable",
26+
state = list(disabled = TRUE)
27+
)
28+
)
29+
),
30+
list(
31+
text = "Drag here:",
32+
type = "target",
33+
state = list(opened = TRUE)
34+
)
35+
)
36+
37+
checkCallback <- JS(
38+
"function(operation, node, parent, position, more) { console.log(node);",
39+
" if(operation === 'copy_node') {",
40+
" if(parent.id === '#' || node.parent !== 'j1_1' || parent.type !== 'target') {",
41+
" return false;", # prevent moving an item above or below the root
42+
" }", # and moving inside an item except a 'target' item
43+
" }",
44+
" return true;", # allow everything else
45+
"}"
46+
)
47+
48+
dnd <- list(
49+
always_copy = TRUE,
50+
is_draggable = JS(
51+
"function(node) {",
52+
" return node[0].type === 'moveable';",
53+
"}"
54+
)
55+
)
56+
57+
customMenu <- JS(
58+
"function customMenu(node) {",
59+
" var tree = $('#mytree').jstree(true);", # 'mytree' is the Shiny id or the elementId
60+
" var items = {",
61+
" 'delete' : {",
62+
" 'label' : 'Delete',",
63+
" 'action' : function (obj) { tree.delete_node(node); },",
64+
" 'icon' : 'glyphicon glyphicon-trash'",
65+
" }",
66+
" }",
67+
" return items;",
68+
"}")
69+
70+
71+
jstree(
72+
nodes, dragAndDrop = TRUE, dnd = dnd, checkCallback = checkCallback,
73+
types = list(moveable = list(), target = list()),
74+
contextMenu = list(items = customMenu),
75+
elementId = "mytree" # don't use elementId in Shiny! use the Shiny id
76+
)

0 commit comments

Comments
 (0)