parent
c5b0176e95
commit
52391c922e
@ -25,6 +25,8 @@ export default class MUCPollFormView extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
_fieldTranslationMap = new Map()
|
||||
|
||||
async initialize () {
|
||||
this.alert_message = undefined
|
||||
if (!this.model) {
|
||||
@ -32,6 +34,7 @@ export default class MUCPollFormView extends CustomElement {
|
||||
return
|
||||
}
|
||||
try {
|
||||
this._initFieldTranslations()
|
||||
const stanza = await this._fetchPollForm()
|
||||
const query = stanza.querySelector('query')
|
||||
const xform = sizzle(`x[xmlns="${Strophe.NS.XFORM}"]`, query)[0]
|
||||
@ -39,9 +42,12 @@ export default class MUCPollFormView extends CustomElement {
|
||||
throw Error('Missing xform in stanza')
|
||||
}
|
||||
|
||||
this.title = xform.querySelector('title')?.textContent ?? ''
|
||||
this.instructions = xform.querySelector('instructions')?.textContent ?? ''
|
||||
// eslint-disable-next-line no-undef
|
||||
this.title = __(LOC_poll_title) // xform.querySelector('title')?.textContent ?? ''
|
||||
// eslint-disable-next-line no-undef
|
||||
this.instructions = __(LOC_poll_instructions) // xform.querySelector('instructions')?.textContent ?? ''
|
||||
this.form_fields = Array.from(xform.querySelectorAll('field')).map(field => {
|
||||
this._translateField(field)
|
||||
return u.xForm2TemplateResult(field, stanza)
|
||||
})
|
||||
} catch (err) {
|
||||
@ -63,6 +69,30 @@ export default class MUCPollFormView extends CustomElement {
|
||||
)
|
||||
}
|
||||
|
||||
_initFieldTranslations () {
|
||||
// eslint-disable-next-line no-undef
|
||||
this._fieldTranslationMap.set('muc#roompoll_question', __(LOC_poll_question))
|
||||
// eslint-disable-next-line no-undef
|
||||
this._fieldTranslationMap.set('muc#roompoll_duration', __(LOC_poll_duration))
|
||||
// eslint-disable-next-line no-undef
|
||||
this._fieldTranslationMap.set('muc#roompoll_anonymous_results', __(LOC_poll_anonymous_results))
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
this._fieldTranslationMap.set(
|
||||
'muc#roompoll_choice' + i.toString(),
|
||||
// eslint-disable-next-line no-undef
|
||||
__(LOC_poll_choice_n).replace('{{N}}', i.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
_translateField (field) {
|
||||
const v = field.getAttribute('var')
|
||||
const label = this._fieldTranslationMap.get(v)
|
||||
if (label) {
|
||||
field.setAttribute('label', label)
|
||||
}
|
||||
}
|
||||
|
||||
async formSubmit (ev) {
|
||||
ev.preventDefault()
|
||||
try {
|
||||
|
@ -7,7 +7,6 @@ import BaseModal from 'plugins/modal/modal.js'
|
||||
import { api } from '@converse/headless/core'
|
||||
import { modal_close_button as ModalCloseButton } from 'plugins/modal/templates/buttons.js'
|
||||
import { html } from 'lit'
|
||||
import 'livechat-external-login-content.js'
|
||||
|
||||
class PollFormModal extends BaseModal {
|
||||
initialize () {
|
||||
|
@ -36,7 +36,13 @@ const locKeys = [
|
||||
'task_list_pick_empty',
|
||||
'task_list_pick_message',
|
||||
'muted_anonymous_message',
|
||||
'new_poll'
|
||||
'new_poll',
|
||||
'poll_question',
|
||||
'poll_duration',
|
||||
'poll_anonymous_results',
|
||||
'poll_choice_n',
|
||||
'poll_title',
|
||||
'poll_instructions'
|
||||
]
|
||||
|
||||
module.exports = locKeys
|
||||
|
@ -565,3 +565,9 @@ livechat_configuration_channel_terms_desc: |
|
||||
You can configure a "terms & conditions" message that will be shown to users joining your chatrooms.
|
||||
|
||||
new_poll: Create a new poll
|
||||
poll_title: New poll
|
||||
poll_instructions: Complete and submit this form to create a new poll. This will end and replace any existing poll.
|
||||
poll_question: Question
|
||||
poll_duration: Poll duration (in minutes)
|
||||
poll_anonymous_results: Anonymous results
|
||||
poll_choice_n: Choice {{N}}
|
||||
|
@ -545,3 +545,12 @@ livechat_configuration_channel_terms_label: Conditions d'utilisation tchat de la
|
||||
livechat_configuration_channel_terms_desc: "Vous pouvez configurer un message de \"\
|
||||
conditions d'utilisation\" qui sera affiché aux utilisateur⋅rices qui rejoignent
|
||||
vos salons de discussion.\n"
|
||||
|
||||
|
||||
new_poll: Créer un nouveau sondage
|
||||
poll_title: Nouveau sondage
|
||||
poll_instructions: Complétez et soumettez ce formulaire pour créer un nouveau sondage. Ceci mettra fin au sondage précédent le cas échéant.
|
||||
poll_question: Question
|
||||
poll_duration: Durée du sondage (en minutes)
|
||||
poll_anonymous_results: Résultats anonymes
|
||||
poll_choice_n: Choix {{N}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user