| ... |
... |
@@ -1,61 +1,64 @@ |
| 1 |
1 |
{{velocity}} |
| 2 |
|
-#if ("$!xcontext.macro.params.columns" != "") |
| 3 |
|
- #set ($collist = []) |
|
2 |
+#if ("$!xcontext.macro.params.columns" != "") |
|
3 |
+ #set ($properties = []) |
| 4 |
4 |
#foreach ($colname in $xcontext.macro.params.columns.split(',')) |
| 5 |
|
- #set ($discard = $collist.add($colname.trim())) |
|
5 |
+ #set ($discard = $properties.add($colname.trim())) |
| 6 |
6 |
#end |
| 7 |
7 |
#else |
| 8 |
|
- #set($collist = ['doc.title', 'doc.location', 'doc.date', 'doc.author']) |
|
8 |
+ #set ($properties = ['doc.title', 'doc.location', 'doc.date', 'doc.author']) |
| 9 |
9 |
#end |
| 10 |
|
-#set($colprops = { |
| 11 |
|
- 'doc.title' : { 'size' : 30, 'link' : 'view' }, |
| 12 |
|
- 'doc.location' : { 'html': true }, |
| 13 |
|
- 'doc.fullName' : { 'size' : 30, 'link' : 'view' }, |
| 14 |
|
- 'doc.name' : { 'size' : 30, 'link' : 'view' }, |
| 15 |
|
- 'doc.space' : { 'link' : 'space' }, |
| 16 |
|
- 'doc.author' : { 'link' : 'author' } |
|
10 |
+#set ($sourceParameters = { |
|
11 |
+ 'translationPrefix' : 'platform.index.' |
| 17 |
17 |
}) |
| 18 |
|
-#set($options = { |
| 19 |
|
- 'translationPrefix' : 'platform.index.', |
| 20 |
|
- 'rowCount' : $xcontext.macro.params.count, |
| 21 |
|
- 'description' : 'This table lists documents found on this wiki based on passed criteria. The columns can be sorted and some can be filtered.' |
| 22 |
|
-}) |
| 23 |
|
-#if ("$!xcontext.macro.params.space" != "") |
| 24 |
|
- #set ($extraParams = "&space=$escapetool.url($xcontext.macro.params.space)") |
|
13 |
+#if ("$!xcontext.macro.params.space" != "") |
|
14 |
+ #set ($discard = $sourceParameters.put('space', $xcontext.macro.params.space)) |
| 25 |
25 |
#end |
| 26 |
|
-#if ("$!xcontext.macro.params.location" != "") |
| 27 |
|
- #set ($extraParams = "$!{extraParams}&location=$escapetool.url($xcontext.macro.params.location)") |
|
16 |
+#if ("$!xcontext.macro.params.location" != "") |
|
17 |
+ #set ($discard = $sourceParameters.put('location', $xcontext.macro.params.location)) |
| 28 |
28 |
#end |
| 29 |
|
-#if ("$!xcontext.macro.params.parent" != "") |
| 30 |
|
- #set ($extraParams = "$!{extraParams}&parent=$escapetool.url($xcontext.macro.params.parent)") |
|
19 |
+#if ("$!xcontext.macro.params.parent" != "") |
|
20 |
+ #set ($discard = $sourceParameters.put('parent', $xcontext.macro.params.parent)) |
| 31 |
31 |
#end |
| 32 |
|
-#if ("$!extraParams" != "") |
| 33 |
|
- #set($discard = $options.put('extraParams', $extraParams)) |
| 34 |
|
-#end |
| 35 |
|
-#if(!$isGuest && $xcontext.macro.params.actions == "true") |
| 36 |
|
- #set($discard = $collist.add('_actions')) |
| 37 |
|
- #set($discard = $colprops.put('_actions', { |
| 38 |
|
- 'actions': ['copy', 'rename', 'rights', 'delete'], |
| 39 |
|
- 'filterable': false, |
| 40 |
|
- 'sortable': false |
| 41 |
|
- })) |
| 42 |
|
-#end |
|
22 |
+#set ($propertyDescriptors = []) |
| 43 |
43 |
#if ("$!services.like" != "") |
| 44 |
|
- #set($discard = $collist.add('_likes')) |
| 45 |
45 |
## We can't make it sortable or filterable right now since it's not stored in DB. |
| 46 |
|
- #set($discard = $colprops.put('_likes', { |
| 47 |
|
- 'filterable': false, |
| 48 |
|
- 'sortable': false |
| 49 |
|
- })) |
|
25 |
+ #set ($discard = $propertyDescriptors.add({ 'id': '_likes', 'sortable': false, 'filterable': false, 'editable': false })) |
|
26 |
+ #set ($discard = $properties.add('_likes')) |
| 50 |
50 |
#end |
| 51 |
|
-#if ($collist.contains('doc.location')) |
| 52 |
|
- #set ($discard = $options.put('selectedColumn','doc.location')) |
|
28 |
+#if(!$isGuest && $xcontext.macro.params.actions == "true") |
|
29 |
+ #set ($discard = $propertyDescriptors.add({ 'id': '_actions', 'displayer': { 'id': 'actions', 'actions': ['copy', 'rename', 'rights', 'delete'] }})) |
|
30 |
+ #set ($discard = $properties.add('_actions')) |
| 53 |
53 |
#end |
|
32 |
+#set ($liveDataConfig = {'meta': {'propertyDescriptors': $propertyDescriptors}}) |
| 54 |
54 |
#if ("$!xcontext.macro.params.id" != "") |
| 55 |
|
- #set ($livetableId = $xcontext.macro.params.id) |
|
34 |
+ #set ($livedataId = $xcontext.macro.params.id) |
| 56 |
56 |
#else |
| 57 |
57 |
## TODO: Improve this since we could have several livetables on the same page with same ids |
| 58 |
|
- #set ($livetableId = "documents-$mathtool.random(1, 1000)") |
|
37 |
+ #set ($livedataId = "documents-$mathtool.random(1, 1000)") |
| 59 |
59 |
#end |
| 60 |
|
-#livetable($livetableId $collist $colprops $options) |
|
39 |
+ |
|
40 |
+#set ($livedataId = $services.rendering.escape($livedataId, 'xwiki/2.1')) |
|
41 |
+#set ($description = '') |
|
42 |
+#if ("$!xcontext.macro.params.description" != '') |
|
43 |
+ #set ($description = $services.rendering.escape($xcontext.macro.params.description, 'xwiki/2.1')) |
|
44 |
+#end |
|
45 |
+#set ($limit = '') |
|
46 |
+#if ("$!xcontext.macro.params.count" != '') |
|
47 |
+ #set ($limit = $services.rendering.escape($xcontext.macro.params.count, 'xwiki/2.1')) |
|
48 |
+#end |
|
49 |
+#set ($propertiesStr = $services.rendering.escape($stringtool.join($properties, ','), 'xwiki/2.1')) |
|
50 |
+#set ($filtersDeclared = $xcontext.macro.params.parameterNames.contains('filters')) |
|
51 |
+#if ($filtersDeclared) |
|
52 |
+ #set ($filters = $services.rendering.escape($xcontext.macro.params.filters, 'xwiki/2.1')) |
|
53 |
+#end |
|
54 |
+{{liveData |
|
55 |
+ id="$livedataId" |
|
56 |
+ properties="$propertiesStr" |
|
57 |
+ source="liveTable" |
|
58 |
+ sourceParameters="$escapetool.url($sourceParameters)" |
|
59 |
+ #if ($filtersDeclared) filters="$filters"#end |
|
60 |
+ #if ($description != '')description="$description"#end |
|
61 |
+ #if ($properties.contains('doc.location'))sort="doc.location"#end |
|
62 |
+ #if ($limit != '')limit="$limit"#end |
|
63 |
+}}$jsontool.serialize($liveDataConfig){{/liveData}} |
| 61 |
61 |
{{/velocity}} |