Skip to content

Commit

Permalink
Can't vote from the Livetable on the Ideas home page #42
Browse files Browse the repository at this point in the history
* the doc name used in the ajax request was not encoded
* in order to get the idea full name, add a new column in the livetable to have the doc.fullName
* since the doc.fullName is not needed for display purpose, the entire column is hidden from CSS as the `type`:`hidden` in the livetable definition does not do the job
  • Loading branch information
acotiuga committed Oct 13, 2020
1 parent 2f1077c commit f21a8fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/main/resources/Ideas/IdeasClass.xml
Expand Up @@ -493,12 +493,7 @@

if(xm.document == 'Ideas.WebHome') {
var docTitle = button.parent().siblings('.doc_title');
docName = xm.space + '.' + docTitle.text();
// Compute the docName for a non terminal idea (the url ends with a "/").
var docUrl = docTitle.children('a').get(0).href;
if (docUrl.length - docUrl.lastIndexOf('/') == 1) {
docName += '.' + 'WebHome';
}
docName = button.parent().siblings('.doc_fullName').text();
}

if(status != "$services.localization.render('Ideas.IdeasClass_status_open')") {
Expand All @@ -518,7 +513,7 @@
}

var url = new XWiki.Document('IdeasVoteService', 'Ideas').getURL('get',
('xpage=plain&outputSyntax=plain&page=' + docName + '&action=' + addVote));
('xpage=plain&outputSyntax=plain&page=' + encodeURIComponent(docName) + '&action=' + addVote));
// Ajax request.
$.ajax({
url : url,
Expand Down Expand Up @@ -735,6 +730,11 @@
}
.no-hover-con:hover, .no-hover-pro:hover {
opacity: 0.5;
}
.xwiki-livetable-display-header tr th:first-child,
.xwiki-livetable-display-header tr td:first-child,
.xwiki-livetable-display-body tr td:first-child {
display: none;
}</code>
</property>
<property>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/Ideas/IdeasHomeSheet.xml
Expand Up @@ -50,6 +50,7 @@ $xwiki.ssx.use("Ideas.IdeasClass")
## Load the User Picker style for the "Assigned to" column
#set($discard = $xwiki.ssfx.use('uicomponents/widgets/userpicker/userPicker.css'))
#set ($columnsProperties = {
'doc.fullName': {'type': 'text'},
'nbvotes': {"type":"number","size":10,"html":true},
'nbagainst': {"type":"number","size":10,"html":true},
'nbestimate': {"type":"number","size":10,"html":true},
Expand All @@ -70,7 +71,7 @@ $xwiki.ssx.use("Ideas.IdeasClass")
'selectedColumn': 'status',
'defaultOrder': 'asc'
})
#set ($columns = ['nbvotes','nbagainst','doc.title','nbestimate','status','priority','assignement','doc.date', 'doc.author', '_actions'])
#set ($columns = ['doc.fullName', 'nbvotes','nbagainst','doc.title', 'nbestimate','status','priority','assignement','doc.date', 'doc.author', '_actions'])
#livetable($doc $columns $columnsProperties $options)
{{/velocity}}</content>
</xwikidoc>

0 comments on commit f21a8fa

Please sign in to comment.