On 01/13/2015 03:05 PM, Pascal BASTIEN wrote:
Thxs a lot to explained me with clarity all of that
and help me to understand better XWiki.
Then with what you give me, I tried to add a format_date parameter () (or regexp) in
columns properties to improve livetable.
I failed because I didn't manage to find where is store livetable macro :-))
Something like this and next add a format date parameter in user index customizer.
#set($columns = ["_avatar", "first_name", "last_name",
"email", "doc.creationDate", "_actions"])
#set($columnsProperties = {
"_avatar" : { "type" : "none", "link" :
"none", "html" : "true", "sortable":false },
"first_name" : { "type" : "text" , "size" :
20, "link" : "view"},
"last_name" : { "type" : "text", "link" :
"view"},
"email" : { "type" : "text" },
"doc.creationDate" : { "type" : "date",
"dateformat":"YYYY-mm" }
})
I am afraid that this does not work.
The supported options are documented here:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro
and a 'dateformat' option is unfortunately not part of it.
The problem is that in the end the #livetable macro turns out to make an AJAX call
to the code at the page XWiki.LiveTableResults , which in turn uses the
XWiki.LiveTableResultsMacros
and the latter just calls $xwiki.formatDate($itemDoc.creationDate)) without any custom
format.
What you can to is:
- either again patch that line of code in the XWiki.LiveTableResultsMacros with a date
format of your choice
- or modify the results afterwards, as explained
http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HCusto…
(scroll down to the "Starting with XWiki Enterprise 4.0 you can modify the default
JSON ...")
the later would involve creating your own livetable result page, i.e.
XWiki.LiveTableResultsNoTime
with e.g. the contents:
{{include reference="XWiki.LiveTableResultsMacros" /}}
{{velocity wiki="false"}}
#if("$!{request.xpage}" == 'plain')
$response.setContentType('application/json')
#end
##==================
## Initialize the map that will store the JSON data.
##==================
#set($map = {})
##==================
## Build the JSON in memory using the previous map
##==================
#gridresult_buildJSON("$!request.classname" $request.collist.split(',')
$map)
##==================
## Modify the JSON data from the map or add new data.
##==================
#foreach($row in $map.get('rows'))
#if($row.get('doc_creationDate'))
#set($creation_date = $row.get('doc_creationDate'))
#set($time_sep_index = $creation_date.indexOf(' '))
#if($time_sep_index >=0)
#set($creation_date_without_time = $creation_date.substring(0, $time_sep_index))
#set($discard = $row.put('doc_creationDate', $creation_date_without_time ))
#end
#end
#end
##==================
## Serialize the map in the JSON format.
##==================
$jsontool.serialize($map)
{{/velocity}}
this mostly copy & paste from the LiveTable docs, expect for the "Modify the JSON
data ..." part,
where the creation date field is simply cut off after the first space - quite hackish, but
should work
for most date formats.
Now when calling that page to get the results, everything must be put inside the
'url' option
so the $options change to:
#set($options = {
"url" : "$xwiki.getURL('XWiki.LiveTableResultsNoTime',
'get',
'outputSyntax=plain&classname=XWiki.XWikiUsers&transprefix=xe.userdirectory.&collist=_avatar,first_name,last_name,email,doc.creationDate')",
"rowCount": 10
})
Afterwards it is just a matter of a few hours debugging with firebug etc until one finds
the missing ')' or '"' that keeps things from working ;)
Oh, and come to think of it, the simplest solution would be to change
the XWiki date format the XWiki Admin to exclude the time - that would remove
the time everywhere, but I know people who actually like it. ;)
#set($options = {
"className":"XWiki.XWikiUsers",
"translationPrefix" : "xe.index.users.",
"tagCloud" : true,
"rowCount": 10
})
#livetable("userdirectory" $columns $columnsProperties $options)
[...]