Poll fixes:
* update poll banner when user role changes * don't show instructions if user can't vote
This commit is contained in:
parent
867c1debd6
commit
914de79400
@ -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 { converse, api } from '@converse/headless/core'
|
import { converse, _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 {
|
||||||
@ -26,6 +26,13 @@ export default class MUCPollView extends CustomElement {
|
|||||||
this.buttonDisabled = false
|
this.buttonDisabled = false
|
||||||
this.requestUpdate()
|
this.requestUpdate()
|
||||||
})
|
})
|
||||||
|
this.listenTo(this.model.occupants, 'change:role', occupant => {
|
||||||
|
if (occupant.get('jid') !== _converse.bare_jid) { // only for myself
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// visitors cant vote. So we must refresh the polls results when current occupant role changes.
|
||||||
|
this.requestUpdate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -16,11 +16,6 @@ converse.plugins.add('livechat-converse-poll', {
|
|||||||
dependencies: ['converse-muc', 'converse-disco'],
|
dependencies: ['converse-muc', 'converse-disco'],
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
// _converse.api.listen.on('chatRoomInitialized', muc => {
|
|
||||||
// muc.features.on('change:' + XMLNS_POLL, () => {
|
|
||||||
// // TODO: refresh headingbuttons?
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// adding the poll actions in the MUC heading buttons:
|
// adding the poll actions in the MUC heading buttons:
|
||||||
_converse.api.listen.on('getHeadingButtons', getHeadingButtons)
|
_converse.api.listen.on('getHeadingButtons', getHeadingButtons)
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import { html } from 'lit'
|
|||||||
import { repeat } from 'lit/directives/repeat.js'
|
import { repeat } from 'lit/directives/repeat.js'
|
||||||
import { __ } from 'i18n'
|
import { __ } from 'i18n'
|
||||||
|
|
||||||
function _tplPollInstructions (el, currentPoll) {
|
function _tplPollInstructions (el, currentPoll, canVote) {
|
||||||
if (currentPoll.over) {
|
if (currentPoll.over || !canVote) {
|
||||||
return html``
|
return html``
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ export function tplPoll (el, currentPoll, canVote) {
|
|||||||
<table><tbody>
|
<table><tbody>
|
||||||
${repeat(currentPoll.choices ?? [], (c) => c.choice, (c) => _tplChoice(el, currentPoll, c, canVote))}
|
${repeat(currentPoll.choices ?? [], (c) => c.choice, (c) => _tplChoice(el, currentPoll, c, canVote))}
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
${_tplPollInstructions(el, currentPoll)}
|
${_tplPollInstructions(el, currentPoll, canVote)}
|
||||||
${_tplPollEnd(el, currentPoll)}
|
${_tplPollEnd(el, currentPoll)}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user