From 8885bb41075251b819b575d515c4341a4c0653e5 Mon Sep 17 00:00:00 2001 From: stla Date: Tue, 7 Jun 2022 23:32:07 +0200 Subject: [PATCH] prepared CRAN submission --- DESCRIPTION | 2 +- NEWS.md | 4 +- README.md | 2 +- cran-comments.md | 2 +- inst/essais/essai_curiousJorge.R | 76 ++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 inst/essais/essai_curiousJorge.R diff --git a/DESCRIPTION b/DESCRIPTION index 7dd30b3..0c6f8b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "laurent_step@outlook.fr", role = c("aut", "cre")), person("jQuery contributors", role = c("ctb", "cph"), comment = "jQuery"), diff --git a/NEWS.md b/NEWS.md index 8dfcf2a..f7e1a15 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# 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. @@ -6,7 +6,7 @@ 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) diff --git a/README.md b/README.md index 9fcb449..7643f39 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![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) A wrapper of the JavaScript library [jsTree](https://www.jstree.com/). diff --git a/cran-comments.md b/cran-comments.md index 0604a18..26ad06f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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 diff --git a/inst/essais/essai_curiousJorge.R b/inst/essais/essai_curiousJorge.R new file mode 100644 index 0000000..52f728b --- /dev/null +++ b/inst/essais/essai_curiousJorge.R @@ -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 +)