Poll WIP (#231):

* backend save WIP
* various fixes
This commit is contained in:
John Livingston
2024-06-29 18:15:04 +02:00
parent 14e0576329
commit a7250efd06
3 changed files with 111 additions and 17 deletions

View File

@ -72,6 +72,7 @@ export default class MUCPollFormView extends CustomElement {
const iq = $iq({
type: 'set',
to: this.model.get('jid'),
id: u.getUniqueId()
}).c('query', { xmlns: XMLNS_POLL })
@ -83,9 +84,19 @@ export default class MUCPollFormView extends CustomElement {
await api.sendIQ(iq)
if (this.modal) {
this.modal.hide()
this.modal.onHide()
}
} catch (err) {
if (u.isErrorStanza(err)) {
// Checking if there is a text error that we can show to the user.
if (sizzle('error bad-request', err).length) {
const text = sizzle('error text', err)
if (text.length) {
this.alert_message = __('Error') + ': ' + text[0].textContent
return
}
}
}
console.error(err)
this.alert_message = __('Error')
}

View File

@ -20,13 +20,9 @@ export function tplPollForm (el) {
${el.form_fields}
${
el.modal
? html`` // no need for submit button, the modal will have one in the footer
: html`<fieldset class="buttons form-group">
<input type="submit" class="btn btn-primary" value="${i18nOk}" />
</fieldset>`
}
<fieldset class="buttons form-group">
<input type="submit" class="btn btn-primary" value="${i18nOk}" />
</fieldset>
</form>`
: ''
}`