diff options
author | René Gieling <github@dartcafe.de> | 2021-05-31 20:35:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 20:35:55 +0300 |
commit | 7d392d24202059c5b90559717baaa03b9bae3dd8 (patch) | |
tree | 99211a32514f307e17e20527cda6b78d0856a9c2 /src | |
parent | 6c4f268e00317776e10024ba833d5ce50bd14793 (diff) |
Add count of votes and options to poll information (#1676)
* Add count of all votes to poll information
* Add options count to poll information
Diffstat (limited to 'src')
-rw-r--r-- | src/js/components/Poll/PollInformation.vue | 26 | ||||
-rw-r--r-- | src/js/store/modules/votes.js | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/js/components/Poll/PollInformation.vue b/src/js/components/Poll/PollInformation.vue index 4538ed97..05c1d679 100644 --- a/src/js/components/Poll/PollInformation.vue +++ b/src/js/components/Poll/PollInformation.vue @@ -51,6 +51,18 @@ <div v-if="participantsVoted.length && acl.allowSeeResults" class="icon-user"> {{ n('polls', '%n Participant', '%n Participants', participantsVoted.length) }} </div> + <div class="icon-polls-unconfirmed"> + {{ n('polls', '%n option', '%n options', countOptions) }} + </div> + <div v-if="countAllYesVotes" class="icon-polls-yes"> + {{ n('polls', '%n yes vote', '%n yes votes', countAllYesVotes) }} + </div> + <div v-if="countAllNoVotes" class="icon-polls-no"> + {{ n('polls', '%n no vote', '%n no votes', countAllNoVotes) }} + </div> + <div v-if="countAllMaybeVotes" class="icon-polls-maybe"> + {{ n('polls', '%n maybe vote', '%n maybe votes', countAllMaybeVotes) }} + </div> <div class="icon-timezone"> {{ t('polls', 'Time zone: {timezoneString}', { timezoneString: currentTimeZone}) }} </div> @@ -103,7 +115,9 @@ export default { participantsVoted: 'poll/participantsVoted', closed: 'poll/isClosed', confirmedOptions: 'options/confirmed', + countOptions: 'options/count', countVotes: 'votes/countVotes', + countAllVotes: 'votes/countAllVotes', proposalsAllowed: 'poll/proposalsAllowed', proposalsExpirySet: 'poll/proposalsExpirySet', proposalsExpired: 'poll/proposalsExpired', @@ -191,6 +205,18 @@ export default { return Intl.DateTimeFormat().resolvedOptions().timeZone }, + countAllYesVotes() { + return this.countAllVotes('yes') + }, + + countAllNoVotes() { + return this.countAllVotes('no') + }, + + countAllMaybeVotes() { + return this.countAllVotes('maybe') + }, + }, } </script> diff --git a/src/js/store/modules/votes.js b/src/js/store/modules/votes.js index 971a624c..ff30ebdb 100644 --- a/src/js/store/modules/votes.js +++ b/src/js/store/modules/votes.js @@ -63,6 +63,8 @@ const getters = { countVotes: (state, getters, rootState) => (answer) => getters.relevant.filter((vote) => vote.userId === rootState.poll.acl.userId && vote.voteAnswer === answer).length, + countAllVotes: (state, getters, rootState) => (answer) => getters.relevant.filter((vote) => vote.voteAnswer === answer).length, + getVote: (state) => (payload) => { const found = state.list.find((vote) => (vote.userId === payload.userId && vote.voteOptionText === payload.option.pollOptionText)) |