Poll WIP (#231):
* muted participants can't vote * removed "Choice N" from button labels.
This commit is contained in:
parent
6dda0cc44f
commit
14ffa90208
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { tplPoll } from '../templates/poll.js'
|
import { tplPoll } from '../templates/poll.js'
|
||||||
import { CustomElement } from 'shared/components/element.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'
|
import '../styles/poll.scss'
|
||||||
|
|
||||||
export default class MUCPollView extends CustomElement {
|
export default class MUCPollView extends CustomElement {
|
||||||
@ -30,7 +30,9 @@ export default class MUCPollView extends CustomElement {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const currentPoll = this.model?.get('current_poll')
|
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) {
|
toggle (ev) {
|
||||||
|
@ -31,9 +31,9 @@ function _tplPollEnd (el, currentPoll) {
|
|||||||
</p>`
|
</p>`
|
||||||
}
|
}
|
||||||
|
|
||||||
function _tplChoice (el, currentPoll, choice) {
|
function _tplChoice (el, currentPoll, choice, canVote) {
|
||||||
// eslint-disable-next-line no-undef
|
// 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 votes = choice.votes
|
||||||
const totalVotes = currentPoll.votes
|
const totalVotes = currentPoll.votes
|
||||||
@ -42,7 +42,7 @@ function _tplChoice (el, currentPoll, choice) {
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
${
|
${
|
||||||
currentPoll.over
|
currentPoll.over || !canVote
|
||||||
? html`${i18nChoiceN}`
|
? html`${i18nChoiceN}`
|
||||||
: html`
|
: html`
|
||||||
<button type="button" class="btn btn-primary btn-sm"
|
<button type="button" class="btn btn-primary btn-sm"
|
||||||
@ -75,7 +75,7 @@ function _tplChoice (el, currentPoll, choice) {
|
|||||||
</tr>`
|
</tr>`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tplPoll (el, currentPoll) {
|
export function tplPoll (el, currentPoll, canVote) {
|
||||||
if (!currentPoll) {
|
if (!currentPoll) {
|
||||||
return html``
|
return html``
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ export function tplPoll (el, currentPoll) {
|
|||||||
? ''
|
? ''
|
||||||
: html`
|
: html`
|
||||||
<table><tbody>
|
<table><tbody>
|
||||||
${repeat(currentPoll.choices ?? [], (c) => c.choice, (c) => _tplChoice(el, currentPoll, c))}
|
${repeat(currentPoll.choices ?? [], (c) => c.choice, (c) => _tplChoice(el, currentPoll, c, canVote))}
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
${_tplPollInstructions(el, currentPoll)}
|
${_tplPollInstructions(el, currentPoll)}
|
||||||
${_tplPollEnd(el, currentPoll)}
|
${_tplPollEnd(el, currentPoll)}
|
||||||
|
@ -20,7 +20,7 @@ All above configurations are optional.
|
|||||||
The priority for the hook that will take into account votes.
|
The priority for the hook that will take into account votes.
|
||||||
You can change this, if you have some specific hook that should be done after/before counting votes (slow mode, firewall, ...).
|
You can change this, if you have some specific hook that should be done after/before counting votes (slow mode, firewall, ...).
|
||||||
|
|
||||||
Default: 500
|
Default: 40 (Prosody checks visitor role with priority of 50, we want this to be after).
|
||||||
|
|
||||||
## Strings
|
## Strings
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ local remove_specific_tags_from_groupchat = module:require("message").remove_spe
|
|||||||
local handle_new_occupant_session = module:require("message").handle_new_occupant_session;
|
local handle_new_occupant_session = module:require("message").handle_new_occupant_session;
|
||||||
local room_restored = module:require("poll").room_restored;
|
local room_restored = module:require("poll").room_restored;
|
||||||
|
|
||||||
local poll_groupchat_votes_priority = module:get_option_number("poll_groupchat_votes_priority") or 500;
|
local poll_groupchat_votes_priority = module:get_option_number("poll_groupchat_votes_priority") or 40;
|
||||||
|
|
||||||
|
|
||||||
-- new poll creation, get form
|
-- new poll creation, get form
|
||||||
|
@ -536,7 +536,6 @@ class ProsodyConfigContent {
|
|||||||
*/
|
*/
|
||||||
usePoll (): void {
|
usePoll (): void {
|
||||||
this.muc.add('modules_enabled', 'muc_poll')
|
this.muc.add('modules_enabled', 'muc_poll')
|
||||||
this.muc.set('poll_groupchat_votes_priority', 1000)
|
|
||||||
this.muc.set('poll_string_over', loc('poll_is_over'))
|
this.muc.set('poll_string_over', loc('poll_is_over'))
|
||||||
this.muc.set('poll_string_invalid_choice', loc('poll_choice_invalid'))
|
this.muc.set('poll_string_invalid_choice', loc('poll_choice_invalid'))
|
||||||
this.muc.set('poll_string_anonymous_vote_ok', loc('poll_anonymous_vote_ok'))
|
this.muc.set('poll_string_anonymous_vote_ok', loc('poll_anonymous_vote_ok'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user