Skip to content

Commit

Permalink
feat: show total vote count in the footer.
Browse files Browse the repository at this point in the history
Additionally hide max vote info once poll is ended or voted.
  • Loading branch information
gianniguida committed Jan 21, 2025
1 parent a788a5e commit f4a50b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/src/forum/components/PollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ export default class PollView extends Component<PollAttrs, PollState> {
);
}

if (poll.canVote()) {
if (poll.canVote() && !poll.hasEnded() && !this.state.hasVoted()) {
items.add(
'max-votes',
<span>
<i className="icon fas fa-poll fa-fw" />
<i className="icon fas fa-chart-bar fa-fw" />
{app.translator.trans('fof-polls.forum.max_votes_allowed', { max: maxVotes })}
</span>
);
Expand All @@ -191,6 +191,16 @@ export default class PollView extends Component<PollAttrs, PollState> {
}
}

if (poll.hasEnded() || this.state.hasVoted()) {
items.add(
'total-vote-count',
<span>
<i className="icon fas fa-chart-bar fa-fw" aria-hidden="true" />
{app.translator.trans('fof-polls.forum.poll.total_votes', { count: poll.voteCount() })}
</span>
);
}

return items;
}

Expand Down
1 change: 1 addition & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fof-polls:
submit_button: Vote
start_poll_button: Start Global Poll
cannot_start_poll_button: Cannot Start Poll
total_votes: "{count, plural, one {# vote was given} other {# votes were given}}"

poll_controls:
edit_label: => core.ref.edit
Expand Down

0 comments on commit f4a50b9

Please sign in to comment.