Changes for page Tree Macro

Last modified by Ludovic Dubost on 2024/07/22 15:50

From version 5.1
edited by Ludovic Dubost
on 2016/10/24 00:53
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro-8.2.1]
To version 1.1
edited by Ludovic Dubost
on 2014/11/18 12:31
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro-6.3]

Summary

Details

XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,15 +3,40 @@
1 -{{template name="tree_macros.vm" /}}
2 -
3 3  {{velocity output="false"}}
4 -#set ($options = {})
5 -#foreach ($parameterName in $xcontext.macro.params.parameterNames)
6 - #set ($discard = $options.put($parameterName, $xcontext.macro.params.get($parameterName)))
2 +#set ($discard = $xwiki.jsx.use($xcontext.macro.doc))
3 +#set ($classes = ['xtree', "$!xcontext.macro.params.get('class')"])
4 +#set ($noLinks = $xcontext.macro.params.links != 'true')
5 +#if ($noLinks)
6 + #set ($discard = $classes.add('jstree-no-links'))
7 7  #end
8 -#set ($content = $xcontext.macro.content)
9 -#if ("$!content" == '' && $xcontext.action == 'edit' && $editor == 'wysiwyg')
10 - #set ($content = "$services.icon.render('chart_organisation') $services.localization.render('tree.macro.editModeWarning')")
8 +#set ($attributes = [
9 + "class='$!escapetool.xml($stringtool.join($classes, ' '))'",
10 + 'data-responsive="true"'
11 +])
12 +#if ("$!xcontext.macro.params.reference" != '')
13 + #set ($reference = $xcontext.macro.params.reference)
14 + #if ($reference.startsWith('path:'))
15 + ## URL/Path reference
16 + #set ($resourceURL = $reference.substring(5))
17 + #else
18 + ## Document reference
19 + #if ($reference.startsWith('doc:'))
20 + #set ($reference = $reference.substring(4))
21 + #end
22 + #set ($resourceURL = $xwiki.getURL($reference, 'get', 'outputSyntax=plain'))
23 + #end
24 + #set ($discard = $attributes.add("data-url='$resourceURL'"))
25 + #set ($discard = $attributes.add("data-root='$!escapetool.xml($xcontext.macro.params.root)'"))
11 11  #end
12 -#set ($output = "(% #treeAttributes($options true) %)((($!content)))")
27 +#set ($dragAndDrop = $xcontext.macro.params.dragAndDrop == 'true')
28 +#set ($discard = $attributes.add("data-dragAndDrop='$dragAndDrop'"))
29 +#set ($contextMenu = $xcontext.macro.params.contextMenu == 'true')
30 +#set ($discard = $attributes.add("data-contextMenu='$contextMenu'"))
31 +#set ($icons = $xcontext.macro.params.icons == 'true')
32 +#set ($discard = $attributes.add("data-icons='$icons'"))
33 +#set ($edges = $xcontext.macro.params.edges == 'true')
34 +#set ($discard = $attributes.add("data-edges='$edges'"))
35 +#set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
36 +#set ($discard = $attributes.add("data-checkboxes='$checkboxes'"))
37 +#set ($output = "(% $stringtool.join($attributes, ' ') %)((($!xcontext.macro.content)))")
13 13  ## Parse the output and return the resulting XDOM blocks.
14 14  #set ($xcontext.macro.result = $services.rendering.parse($output, $xwiki.currentContentSyntaxId).children)
15 15  {{/velocity}}
XWiki.WikiMacroParameterClass[9]
Parameter description
... ... @@ -1,1 +1,0 @@
1 -The id of the node to open the tree to. All the ancestors of the specified node, up to the root of the tree, will be opened also.
Parameter mandatory
... ... @@ -1,1 +1,0 @@
1 -No
Parameter name
... ... @@ -1,1 +1,0 @@
1 -openTo
XWiki.WikiMacroParameterClass[10]
Parameter default value
... ... @@ -1,1 +1,0 @@
1 -false
Parameter description
... ... @@ -1,1 +1,0 @@
1 -Show a text input that can be used to find tree nodes. The input is displayed above the tree and offers suggestions as you type based on the content of the tree. When a suggestion is selected the tree is expanded up to the corresponding node.
Parameter mandatory
... ... @@ -1,1 +1,0 @@
1 -No
Parameter name
... ... @@ -1,1 +1,0 @@
1 -finder
XWiki.WikiMacroParameterClass[11]
Parameter default value
... ... @@ -1,1 +1,0 @@
1 -false
Parameter description
... ... @@ -1,1 +1,0 @@
1 -Whether to show the root node or not. The root node is not shown by default because it is usually implied from the context where the tree is displayed (e.g. a label before the tree). There are some cases though when you may want to display the root node: to be able to create a new node under the root.
Parameter mandatory
... ... @@ -1,1 +1,0 @@
1 -No
Parameter name
... ... @@ -1,1 +1,0 @@
1 -showRoot
XWiki.WikiMacroParameterClass[12]
Parameter default value
... ... @@ -1,1 +1,0 @@
1 -15
Parameter description
... ... @@ -1,1 +1,0 @@
1 -The maximum number of child nodes to display when expanding a parent node for the first time. The rest of the child nodes are accessible through a "more ..." link. This parameter is basically used to paginate the child nodes and thus helps the tree scale when the number of child nodes is large. The tree passes this parameter to the tree source so it works only with dynamic trees whose source implements child count limit.
Parameter mandatory
... ... @@ -1,1 +1,0 @@
1 -No
Parameter name
... ... @@ -1,1 +1,0 @@
1 -limit
XWiki.JavaScriptExtension[0]
Caching policy
... ... @@ -1,0 +1,1 @@
1 +long
Code
... ... @@ -1,0 +1,34 @@
1 +/*
2 +#set ($jsTreeVersion = '3.0.8')
3 +*/
4 +require.config({
5 + paths: {
6 + jsTree: [
7 + '//cdnjs.cloudflare.com/ajax/libs/jstree/$jsTreeVersion/jstree.min',
8 + "$!services.webjars.url('jstree', 'jstree.min.js')"
9 + ],
10 + JobRunner: "$!services.webjars.url('org.xwiki.platform:xwiki-platform-job-webjar', 'jobRunner.min.js')",
11 + tree: "$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.js')"
12 + },
13 + shim: {
14 + jsTree: {
15 + deps: ['jquery']
16 + }
17 + }
18 +});
19 +
20 +(function loadCss(urls) {
21 + for (var i = 0; i < urls.length; i++) {
22 + var link = document.createElement("link");
23 + link.type = "text/css";
24 + link.rel = "stylesheet";
25 + link.href = urls[i];
26 + document.getElementsByTagName("head")[0].appendChild(link);
27 + }
28 +})([
29 + "$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.css', {'evaluate': true})"
30 +]);
31 +
32 +require(['tree'], function($) {
33 + $('.xtree').xtree();
34 +});
Name
... ... @@ -1,0 +1,1 @@
1 +Require Configuration
Parse content
... ... @@ -1,0 +1,1 @@
1 +Yes
Use this extension
... ... @@ -1,0 +1,1 @@
1 +onDemand