From 5962ae048e5ed2cb51fccc39a920f5fd99366efa Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Fri, 18 Oct 2024 18:11:04 +0200 Subject: [PATCH] feat: allow owners and moderators to export poll to JSON file Signed-off-by: Maksim Sukharev --- .../NewMessage/NewMessagePollEditor.vue | 17 +++++++ src/components/PollViewer/PollViewer.vue | 48 +++++++++++++++---- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/components/NewMessage/NewMessagePollEditor.vue b/src/components/NewMessage/NewMessagePollEditor.vue index 008c912b9367..2181d4f29747 100644 --- a/src/components/NewMessage/NewMessagePollEditor.vue +++ b/src/components/NewMessage/NewMessagePollEditor.vue @@ -82,6 +82,12 @@ {{ t('spreed', 'Save as draft') }} + + + {{ t('spreed', 'Export draft to file') }} + {{ t('spreed', 'Create poll') }} @@ -95,12 +101,14 @@ import { computed, nextTick, reactive, ref } from 'vue' import IconArrowLeft from 'vue-material-design-icons/ArrowLeft.vue' import Close from 'vue-material-design-icons/Close.vue' +import IconFileDownload from 'vue-material-design-icons/FileDownload.vue' import IconFileEdit from 'vue-material-design-icons/FileEdit.vue' import Plus from 'vue-material-design-icons/Plus.vue' import { t } from '@nextcloud/l10n' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' +import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js' import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' @@ -160,6 +168,15 @@ const isMultipleAnswer = computed({ }) const isModerator = computed(() => (store.getters as unknown).isModerator) + +const exportPollBlob = () => { + const jsonString = JSON.stringify(pollForm, null, 2) + const blob = new Blob([jsonString], { type: 'application/json' }) + + return URL.createObjectURL(blob) +} +const exportPollFileName = `Talk Poll ${new Date().toISOString().slice(0, 10)}` + /** * Remove a previously added option * @param index option index diff --git a/src/components/PollViewer/PollViewer.vue b/src/components/PollViewer/PollViewer.vue index a9db98079e7a..179284201f91 100644 --- a/src/components/PollViewer/PollViewer.vue +++ b/src/components/PollViewer/PollViewer.vue @@ -78,6 +78,12 @@ {{ t('spreed', 'Save as draft') }} + + + {{ t('spreed', 'Export draft to file') }} + {{ t('spreed', 'End poll') }}