From 1249f0895d2bfc32b791b52241c576bc45f40a33 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 4 Jul 2024 15:34:32 +0200 Subject: [PATCH] Poll WIP (#231): * close button * backend fix --- conversejs/custom/plugins/poll/components/poll-view.js | 5 +++++ conversejs/custom/plugins/poll/index.js | 2 +- conversejs/custom/plugins/poll/styles/poll.scss | 6 ++++++ conversejs/custom/plugins/poll/templates/poll.js | 6 ++++++ prosody-modules/mod_muc_poll/message.lib.lua | 5 +++++ prosody-modules/mod_muc_poll/poll.lib.lua | 3 ++- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/conversejs/custom/plugins/poll/components/poll-view.js b/conversejs/custom/plugins/poll/components/poll-view.js index 53d7e939..8742f044 100644 --- a/conversejs/custom/plugins/poll/components/poll-view.js +++ b/conversejs/custom/plugins/poll/components/poll-view.js @@ -53,6 +53,11 @@ export default class MUCPollView extends CustomElement { body: '!' + choice.choice }) } + + closePoll (ev) { + ev.preventDefault() + this.model.set('current_poll', undefined) + } } api.elements.define('livechat-converse-muc-poll', MUCPollView) diff --git a/conversejs/custom/plugins/poll/index.js b/conversejs/custom/plugins/poll/index.js index adf72ca7..b87f804c 100644 --- a/conversejs/custom/plugins/poll/index.js +++ b/conversejs/custom/plugins/poll/index.js @@ -71,7 +71,7 @@ converse.plugins.add('livechat-converse-poll', { return this.__super__.onMessage(attrs) } // We intercept poll messages, to show the banner. - // Note: we also show the message in the chat. + // Note: we also show poll end messages in the chat, so that the user don't loose the result. if (attrs.is_delayed || attrs.is_archived) { if (attrs.current_poll.over) { console.info('Got a delayed/archived poll message for an poll that is over, just displaying in the chat') diff --git a/conversejs/custom/plugins/poll/styles/poll.scss b/conversejs/custom/plugins/poll/styles/poll.scss index ca5476ec..81ac2dd8 100644 --- a/conversejs/custom/plugins/poll/styles/poll.scss +++ b/conversejs/custom/plugins/poll/styles/poll.scss @@ -23,6 +23,12 @@ padding-right: 0.25em; } + .livechat-poll-close { + background: unset; + border: 0; + float: right; + } + p.livechat-poll-question { text-align: center; font-weight: bold; diff --git a/conversejs/custom/plugins/poll/templates/poll.js b/conversejs/custom/plugins/poll/templates/poll.js index 703cb114..e4367126 100644 --- a/conversejs/custom/plugins/poll/templates/poll.js +++ b/conversejs/custom/plugins/poll/templates/poll.js @@ -82,6 +82,12 @@ export function tplPoll (el, currentPoll) { return html`

+ ${currentPoll.over + ? html`` + : '' + } ${el.collapsed ? html`