From 14ffa90208a1fc5e48f7d07475179c10cee68497 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Fri, 5 Jul 2024 11:00:37 +0200 Subject: [PATCH] Poll WIP (#231): * muted participants can't vote * removed "Choice N" from button labels. --- conversejs/custom/plugins/poll/components/poll-view.js | 6 ++++-- conversejs/custom/plugins/poll/templates/poll.js | 10 +++++----- prosody-modules/mod_muc_poll/README.md | 2 +- prosody-modules/mod_muc_poll/mod_muc_poll.lua | 2 +- server/lib/prosody/config/content.ts | 1 - 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/conversejs/custom/plugins/poll/components/poll-view.js b/conversejs/custom/plugins/poll/components/poll-view.js index 422aba72..e96b5f3b 100644 --- a/conversejs/custom/plugins/poll/components/poll-view.js +++ b/conversejs/custom/plugins/poll/components/poll-view.js @@ -4,7 +4,7 @@ import { tplPoll } from '../templates/poll.js' import { CustomElement } from 'shared/components/element.js' -import { api } from '@converse/headless/core' +import { converse, api } from '@converse/headless/core' import '../styles/poll.scss' export default class MUCPollView extends CustomElement { @@ -30,7 +30,9 @@ export default class MUCPollView extends CustomElement { render () { const currentPoll = this.model?.get('current_poll') - return tplPoll(this, currentPoll) + const entered = this.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED + const canVote = entered && this.model.getOwnRole() !== 'visitor' + return tplPoll(this, currentPoll, canVote) } toggle (ev) { diff --git a/conversejs/custom/plugins/poll/templates/poll.js b/conversejs/custom/plugins/poll/templates/poll.js index bd976b6d..03ad095f 100644 --- a/conversejs/custom/plugins/poll/templates/poll.js +++ b/conversejs/custom/plugins/poll/templates/poll.js @@ -31,9 +31,9 @@ function _tplPollEnd (el, currentPoll) {

` } -function _tplChoice (el, currentPoll, choice) { +function _tplChoice (el, currentPoll, choice, canVote) { // eslint-disable-next-line no-undef - const i18nChoiceN = __(LOC_poll_choice_n).replace('{{N}}', choice.choice) + const i18nChoiceN = '' + choice.choice + ':' const votes = choice.votes const totalVotes = currentPoll.votes @@ -42,7 +42,7 @@ function _tplChoice (el, currentPoll, choice) { ${ - currentPoll.over + currentPoll.over || !canVote ? html`${i18nChoiceN}` : html`