Skip to content
Snippets Groups Projects
Commit dc351226 authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-11453: Add a parameter to open the tree to a specified node

parent dee514bd
No related branches found
No related tags found
No related merge requests found
......@@ -212,7 +212,7 @@
#set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
{{tree reference="path:$xwiki.getURL($xcontext.macro.doc.documentReference, 'get', $escapetool.url($resourceParams))"
root="$!xcontext.macro.params.root" dragAndDrop="$editable" contextMenu="$editable" icons="$isFullWidthAvailable"
edges="$isFullWidthAvailable" links="$links" checkboxes="$checkboxes" /}}
edges="$isFullWidthAvailable" links="$links" checkboxes="$checkboxes" openTo="$!xcontext.macro.params.openTo" /}}
{{/velocity}}</code>
</property>
<property>
......@@ -1164,4 +1164,70 @@
<name>checkboxes</name>
</property>
</object>
<object>
<name>XWiki.DocumentTree</name>
<number>14</number>
<className>XWiki.WikiMacroParameterClass</className>
<guid>a0b559b9-36f6-4682-84f2-6d1e1d8fefa9</guid>
<class>
<name>XWiki.WikiMacroParameterClass</name>
<customClass/>
<customMapping/>
<defaultViewSheet/>
<defaultEditSheet/>
<defaultWeb/>
<nameField/>
<validationScript/>
<defaultValue>
<disabled>0</disabled>
<name>defaultValue</name>
<number>4</number>
<prettyName>Parameter default value</prettyName>
<size>30</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
</defaultValue>
<description>
<disabled>0</disabled>
<name>description</name>
<number>2</number>
<prettyName>Parameter description</prettyName>
<rows>5</rows>
<size>40</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType>
</description>
<mandatory>
<disabled>0</disabled>
<displayFormType>select</displayFormType>
<displayType>yesno</displayType>
<name>mandatory</name>
<number>3</number>
<prettyName>Parameter mandatory</prettyName>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.BooleanClass</classType>
</mandatory>
<name>
<disabled>0</disabled>
<name>name</name>
<number>1</number>
<prettyName>Parameter name</prettyName>
<size>30</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
</name>
</class>
<property>
<defaultValue/>
</property>
<property>
<description>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. The format of the node id is the one used for the root parameter.</description>
</property>
<property>
<mandatory>0</mandatory>
</property>
<property>
<name>openTo</name>
</property>
</object>
</xwikidoc>
......@@ -214,7 +214,15 @@
]);
require(['tree'], function($) {
$('.xtree').xtree();
$('.xtree').xtree().one('ready.jstree', function(event, data) {
var tree = data.instance;
var openToNodeId = tree.element.attr('data-openTo');
// Open the tree to the specified node.
openToNodeId &amp;&amp; data.instance.openTo(openToNodeId, function() {
// Select the node only if the node label doesn't behave as link (otherwise we're going to open the link).
tree.element.hasClass('jstree-no-links') &amp;&amp; tree.select_node(openToNodeId);
});
});
});</code>
</property>
<property>
......@@ -378,6 +386,7 @@
#set ($discard = $attributes.add("data-edges='$edges'"))
#set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
#set ($discard = $attributes.add("data-checkboxes='$checkboxes'"))
#set ($discard = $attributes.add("data-openTo='$!escapetool.xml($xcontext.macro.params.openTo)'"))
#set ($content = $xcontext.macro.content)
#if ("$!content" == '' &amp;&amp; $xcontext.action == 'edit')
#set ($content = "$services.icon.render('chart_organisation') This tree can't be displayed in edit mode.")
......@@ -1006,4 +1015,70 @@
<name>checkboxes</name>
</property>
</object>
<object>
<name>Macros.Tree</name>
<number>9</number>
<className>XWiki.WikiMacroParameterClass</className>
<guid>6468cb7d-a8a5-496e-a98b-8c542006b13d</guid>
<class>
<name>XWiki.WikiMacroParameterClass</name>
<customClass/>
<customMapping/>
<defaultViewSheet/>
<defaultEditSheet/>
<defaultWeb/>
<nameField/>
<validationScript/>
<defaultValue>
<disabled>0</disabled>
<name>defaultValue</name>
<number>4</number>
<prettyName>Parameter default value</prettyName>
<size>30</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
</defaultValue>
<description>
<disabled>0</disabled>
<name>description</name>
<number>2</number>
<prettyName>Parameter description</prettyName>
<rows>5</rows>
<size>40</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType>
</description>
<mandatory>
<disabled>0</disabled>
<displayFormType>select</displayFormType>
<displayType>yesno</displayType>
<name>mandatory</name>
<number>3</number>
<prettyName>Parameter mandatory</prettyName>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.BooleanClass</classType>
</mandatory>
<name>
<disabled>0</disabled>
<name>name</name>
<number>1</number>
<prettyName>Parameter name</prettyName>
<size>30</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
</name>
</class>
<property>
<defaultValue/>
</property>
<property>
<description>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.</description>
</property>
<property>
<mandatory>0</mandatory>
</property>
<property>
<name>openTo</name>
</property>
</object>
</xwikidoc>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment