From 15b322c05f4ee84ee421d55b430fb22a35778b6b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 21 Aug 2020 00:50:53 +0200 Subject: [PATCH] Update the number of votes in a poll after voting --- com.woltlab.wcf/templates/poll.tpl | 2 +- wcfsetup/install/files/js/WCF.Poll.js | 4 ++++ wcfsetup/install/files/lib/action/PollAction.class.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/poll.tpl b/com.woltlab.wcf/templates/poll.tpl index f95bcb514f..a897291f21 100644 --- a/com.woltlab.wcf/templates/poll.tpl +++ b/com.woltlab.wcf/templates/poll.tpl @@ -9,7 +9,7 @@
-

{$poll->question} {#$poll->votes}

+

{$poll->question} {#$poll->votes}

{if !$__wcf->getUser()->userID} diff --git a/wcfsetup/install/files/js/WCF.Poll.js b/wcfsetup/install/files/js/WCF.Poll.js index e8d8cd1fcc..68d0207d1d 100644 --- a/wcfsetup/install/files/js/WCF.Poll.js +++ b/wcfsetup/install/files/js/WCF.Poll.js @@ -603,6 +603,10 @@ WCF.Poll.Manager = Class.extend({ this._canViewParticipants[$pollID] = true; } + var totalVotes = elBySel('.jsPollTotalVotes', this._polls[$pollID][0]); + totalVotes.textContent = WCF.String.formatNumeric(data.totalVotes); + elData(totalVotes, 'tooltip', data.totalVotesTooltip); + this._showResult(null, $pollID); break; } diff --git a/wcfsetup/install/files/lib/action/PollAction.class.php b/wcfsetup/install/files/lib/action/PollAction.class.php index 3c05b13b05..ac588e1646 100644 --- a/wcfsetup/install/files/lib/action/PollAction.class.php +++ b/wcfsetup/install/files/lib/action/PollAction.class.php @@ -201,5 +201,7 @@ class PollAction extends AJAXProxyAction { } $returnValues['canVote'] = $this->poll->isChangeable ? 1 : 0; + $returnValues['totalVotes'] = $this->poll->votes; + $returnValues['totalVotesTooltip'] = WCF::getLanguage()->getDynamicVariable('wcf.poll.totalVotes', ['poll' => $this->poll]); } } -- 2.20.1