From 1dd81b4cad3a917af9811258ecf11c5b0b778ece Mon Sep 17 00:00:00 2001
From: Maksim Sukharev
Date: Mon, 14 Oct 2024 13:18:29 +0200
Subject: [PATCH] feat: browse poll drafts from poll editor and shared items
Signed-off-by: Maksim Sukharev
---
.../Message/MessagePart/Poll.vue | 31 ++++++-
src/components/NewMessage/NewMessage.vue | 13 +++
.../NewMessage/NewMessagePollEditor.vue | 26 +++++-
.../PollViewer/PollDraftHandler.vue | 84 +++++++++++++++++++
.../SharedItems/SharedItemsTab.vue | 24 ++++++
5 files changed, 174 insertions(+), 4 deletions(-)
create mode 100644 src/components/PollViewer/PollDraftHandler.vue
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue
index ae9f9423a735..07950d4b2ec5 100644
--- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue
+++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue
@@ -5,7 +5,16 @@
-
+
+
+
+ 0
? t('spreed', 'Open poll • You voted already')
: t('spreed', 'Open poll • Click to vote')
+ } else if (this.draft) {
+ return n('spreed', 'Poll draft • %n option', 'Poll draft • %n options', this.poll?.options?.length)
} else {
return this.poll?.status === POLL.STATUS.CLOSED
? t('spreed', 'Poll • Ended')
@@ -101,6 +121,7 @@ export default {
methods: {
t,
+ n,
getPollData() {
if (!this.poll) {
this.pollsStore.getPollData({
@@ -110,6 +131,10 @@ export default {
}
},
+ openDraft() {
+ this.$emit('click', this.id)
+ },
+
openPoll() {
this.pollsStore.setActivePoll({
token: this.token,
diff --git a/src/components/NewMessage/NewMessage.vue b/src/components/NewMessage/NewMessage.vue
index 1bb94893d417..29efd484c0c6 100644
--- a/src/components/NewMessage/NewMessage.vue
+++ b/src/components/NewMessage/NewMessage.vue
@@ -151,6 +151,10 @@
:token="token"
@close="togglePollEditor" />
+
+
{{ t('spreed', 'Question') }}
-
+
+
+
+
+
+
+
+ {{ t('spreed', 'Browse poll drafts') }}
+
+
+
@@ -93,6 +103,7 @@ import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import { useStore } from '../../composables/useStore.js'
import { POLL } from '../../constants.js'
import { hasTalkFeature } from '../../services/CapabilitiesManager.ts'
+import { EventBus } from '../../services/EventBus.js'
import { usePollsStore } from '../../stores/polls.ts'
import type { createPollParams } from '../../types/index.ts'
@@ -181,10 +192,23 @@ async function createPollDraft() {
showSuccess(t('spreed', 'Poll draft has been saved'))
}
}
+
+/**
+ * Open a PollDraftHandler dialog
+ */
+function openPollDraftHandler() {
+ EventBus.emit('poll-drafts-open')
+}
diff --git a/src/components/RightSidebar/SharedItems/SharedItemsTab.vue b/src/components/RightSidebar/SharedItems/SharedItemsTab.vue
index e2198d4beacc..62e16f08c093 100644
--- a/src/components/RightSidebar/SharedItems/SharedItemsTab.vue
+++ b/src/components/RightSidebar/SharedItems/SharedItemsTab.vue
@@ -8,6 +8,14 @@
+
+
+
+
+ {{ t('spreed', 'Browse poll drafts') }}
+
@@ -68,6 +76,7 @@