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 2.1
edited by Ludovic Dubost
on 2015/09/01 11:46
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro-7.1]

Summary

Details

XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,15 +3,53 @@
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.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.css',
3 + {'evaluate': true}), {'type': 'text/css', 'rel': 'stylesheet'}))
4 +#set ($discard = $xwiki.jsx.use($xcontext.macro.doc))
5 +#set ($classes = ['xtree', "$!xcontext.macro.params.get('class')"])
6 +#set ($noLinks = $xcontext.macro.params.links != 'true')
7 +#if ($noLinks)
8 + #set ($discard = $classes.add('jstree-no-links'))
7 7  #end
10 +#set ($attributes = [
11 + "class='$!escapetool.xml($stringtool.join($classes, ' '))'",
12 + 'data-responsive="true"'
13 +])
14 +#if ("$!xcontext.macro.params.reference" != '')
15 + #set ($reference = $xcontext.macro.params.reference)
16 + #if ($reference.startsWith('path:'))
17 + ## URL/Path reference
18 + #set ($resourceURL = $reference.substring(5))
19 + #else
20 + ## Document reference
21 + #if ($reference.startsWith('doc:'))
22 + #set ($reference = $reference.substring(4))
23 + #end
24 + #set ($resourceURL = $xwiki.getURL($reference, 'get', 'outputSyntax=plain'))
25 + #end
26 + #set ($discard = $attributes.add("data-url='$resourceURL'"))
27 + #set ($discard = $attributes.add("data-root='$!escapetool.xml($xcontext.macro.params.root)'"))
28 +#end
29 +#set ($dragAndDrop = $xcontext.macro.params.dragAndDrop == 'true')
30 +#set ($discard = $attributes.add("data-dragAndDrop='$dragAndDrop'"))
31 +#set ($contextMenu = $xcontext.macro.params.contextMenu == 'true')
32 +#set ($discard = $attributes.add("data-contextMenu='$contextMenu'"))
33 +#set ($icons = $xcontext.macro.params.icons == 'true')
34 +#set ($discard = $attributes.add("data-icons='$icons'"))
35 +#set ($edges = $xcontext.macro.params.edges == 'true')
36 +#set ($discard = $attributes.add("data-edges='$edges'"))
37 +#set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
38 +#set ($discard = $attributes.add("data-checkboxes='$checkboxes'"))
39 +#set ($discard = $attributes.add("data-openTo='$!escapetool.xml($xcontext.macro.params.openTo)'"))
40 +#set ($finder = $xcontext.macro.params.finder == 'true')
41 +#if ($finder)
42 + #set ($discard = $xwiki.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar',
43 + 'finder.min.css', {'evaluate': true}), {'type': 'text/css', 'rel': 'stylesheet'}))
44 +#end
45 +#set ($discard = $attributes.add("data-finder='$finder'"))
8 8  #set ($content = $xcontext.macro.content)
9 -#if ("$!content" == '' && $xcontext.action == 'edit' && $editor == 'wysiwyg')
47 +#if ("$!content" == '' && $xcontext.action == 'edit')
10 10   #set ($content = "$services.icon.render('chart_organisation') $services.localization.render('tree.macro.editModeWarning')")
11 11  #end
12 -#set ($output = "(% #treeAttributes($options true) %)((($!content)))")
50 +#set ($output = "(% $stringtool.join($attributes, ' ') %)((($!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[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,10 @@
1 +require(["$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'require-config.min.js', {'evaluate': true})"], function() {
2 + require(['tree'], function($) {
3 + $('.xtree').xtree().one('ready.jstree', function(event, data) {
4 + var tree = data.instance;
5 + var openToNodeId = tree.element.attr('data-openTo');
6 + // Open the tree to the specified node and select it.
7 + openToNodeId && data.instance.openTo(openToNodeId);
8 + });
9 + });
10 +});
Name
... ... @@ -1,0 +1,1 @@
1 +Initialization Code
Parse content
... ... @@ -1,0 +1,1 @@
1 +Yes
Use this extension
... ... @@ -1,0 +1,1 @@
1 +onDemand