Skip to content

Commit

Permalink
Merge pull request #50 from CamiAndrei/48
Browse files Browse the repository at this point in the history
Deleted user appears as "Failed to execute the [useravatar] macro" #48
  • Loading branch information
oanalavinia committed Oct 14, 2019
2 parents 4791aea + 1355814 commit 08cb568
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions application-xpoll-ui/src/main/resources/XPoll/XPollSheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,23 @@
#macro (displayUser $user)
{{html wiki='true' clean='false'}}
<div class='clearfix user'>
<span id="avatar_$user.fullName" class='avatar user-avatar-wrapper'>
<span class="user-avatar">
<span id="avatar_$user.fullName" class='avatar user-avatar-wrapper'>
<span class="user-avatar">
#if ($xwiki.exists($user))
{{useravatar username="$user.prefixedFullName" width='40' height='40'/}}
</span>
#else
<img alt="Picture of $user.documentReference.name" src="$xwiki.getSkinFile('icons/xwiki/noavatar.png')"
title="$user.documentReference.name" width="40" height="40">
#end
</span>
<span class='info'>
</span>
<span class='info'>
#if ($xwiki.exists($user))
[[$user.getValue('first_name') $user.getValue('last_name')>>$user.prefixedFullName]]
<br/>
<span class="user-alias">$user.name</span>
</span>
#end
<span class="user-alias">$user.name</span>
</span>
</div>
{{/html}}
#end
Expand Down Expand Up @@ -125,6 +132,14 @@
#set ($status = $doc.getValue('status'))
#set ($proposals = $doc.getValue('proposals'))
#set ($usersCount = $doc.getObjects('XPoll.XPollVoteClass').size())
## Count only the existing users, without the deleted users.
## This is needed to update the number of user when the status is active and the deleted users are hidden.
#set ($usersCountActive = 0)
#foreach ($obj in $doc.getObjects('XPoll.XPollVoteClass'))
#if ($xwiki.exists($obj.user))
#set ($usersCountActive = $usersCountActive + 1)
#end
#end
#set ($totalVotesCount = 0)
#if ($status == 'active')
#set ($voteCount = {})
Expand All @@ -146,7 +161,7 @@
<tr>
<th>
$services.localization.render('contrib.xpoll.user')
<span class='count'>($usersCount)</span>
<span class='count'>($usersCountActive)</span>
</th>
#foreach($proposal in $proposals) <th> $proposal </th> #end
</tr>
Expand All @@ -166,20 +181,22 @@
#set ($foundUser = true)
#end
#set ($votes = $doc.getValue('votes'))
<td>
#displayUser($xwiki.getDocument($user))
</td>
#foreach ($proposal in $proposals)
#set ($checked = $votes.contains($proposal))
#if ($checked)
#set ($nbvotes = $voteCount.get($proposal))
#set ($nbvotes = $nbvotes + 1)
#set ($discard = $voteCount.put($proposal, $nbvotes))
#end ##
#if ($xwiki.exists($user))
<td>
<input type="checkbox" name="${proposal.hashCode()}"
#if ($checked)CHECKED#end #if ($xcontext.user != $user) disabled #end />
#displayUser($xwiki.getDocument($user))
</td>
#foreach ($proposal in $proposals)
#set ($checked = $votes.contains($proposal))
#if ($checked)
#set ($nbvotes = $voteCount.get($proposal))
#set ($nbvotes = $nbvotes + 1)
#set ($discard = $voteCount.put($proposal, $nbvotes))
#end ##
<td>
<input type="checkbox" name="${proposal.hashCode()}"
#if ($checked)CHECKED#end #if ($xcontext.user != $user) disabled #end />
</td>
#end
#end ##
</tr>
#end
Expand Down

0 comments on commit 08cb568

Please sign in to comment.