2024-06-28 16:38:59 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-09-09 18:01:25 +00:00
|
|
|
// FIXME: @stylistic/indent is buggy with strings literrals.
|
|
|
|
/* eslint-disable @stylistic/indent */
|
|
|
|
|
2024-07-05 10:41:02 +00:00
|
|
|
import { converseLocalizedHelpUrl } from '../../../shared/lib/help'
|
2024-06-28 16:38:59 +00:00
|
|
|
import { html } from 'lit'
|
|
|
|
import { __ } from 'i18n'
|
2024-07-11 16:22:59 +00:00
|
|
|
import { converse } from '@converse/headless'
|
|
|
|
|
|
|
|
const u = converse.env.utils
|
|
|
|
|
2024-06-28 16:38:59 +00:00
|
|
|
export function tplPollForm (el) {
|
|
|
|
const i18nOk = __('Ok')
|
2024-07-05 10:41:02 +00:00
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
const i18nHelp = __(LOC_online_help)
|
|
|
|
const helpUrl = converseLocalizedHelpUrl({
|
|
|
|
page: 'documentation/user/streamers/polls'
|
|
|
|
})
|
2024-06-28 16:38:59 +00:00
|
|
|
|
2024-07-11 16:22:59 +00:00
|
|
|
let formFieldTemplates
|
|
|
|
if (el.xform) {
|
|
|
|
const fields = el.xform.fields
|
|
|
|
formFieldTemplates = fields.map(field => {
|
|
|
|
return u.xFormField2TemplateResult(field)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-06-28 16:38:59 +00:00
|
|
|
return html`
|
|
|
|
${el.alert_message ? html`<div class="error">${el.alert_message}</div>` : ''}
|
|
|
|
${
|
2024-07-11 16:22:59 +00:00
|
|
|
formFieldTemplates
|
2024-06-28 16:38:59 +00:00
|
|
|
? html`
|
|
|
|
<form class="converse-form" @submit=${ev => el.formSubmit(ev)}>
|
2024-07-05 10:41:02 +00:00
|
|
|
<p class="title">
|
|
|
|
${el.title}
|
|
|
|
<a href="${helpUrl}" target="_blank"><converse-icon
|
|
|
|
class="fa fa-circle-question"
|
|
|
|
size="1em"
|
|
|
|
title="${i18nHelp}"
|
|
|
|
></converse-icon></a>
|
|
|
|
</p>
|
2024-06-28 16:38:59 +00:00
|
|
|
<p class="form-help instructions">${el.instructions}</p>
|
|
|
|
<div class="form-errors hidden"></div>
|
|
|
|
|
2024-07-11 16:22:59 +00:00
|
|
|
${formFieldTemplates}
|
2024-06-28 16:38:59 +00:00
|
|
|
|
2024-08-05 13:54:03 +00:00
|
|
|
<fieldset class="buttons">
|
2024-06-29 16:15:04 +00:00
|
|
|
<input type="submit" class="btn btn-primary" value="${i18nOk}" />
|
|
|
|
</fieldset>
|
2024-06-28 16:38:59 +00:00
|
|
|
</form>`
|
|
|
|
: ''
|
|
|
|
}`
|
|
|
|
}
|