-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Maksim Sukharev <[email protected]>
- Loading branch information
Showing
9 changed files
with
93 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<script setup lang="ts"> | ||
import { nextTick, computed, onMounted, onBeforeUnmount, ref } from 'vue' | ||
|
||
import PollDraftHandler from './PollDraftHandler.vue' | ||
import PollEditor from './PollEditor.vue' | ||
|
||
import { useStore } from '../../composables/useStore.js' | ||
import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' | ||
import { EventBus } from '../../services/EventBus.ts' | ||
|
||
const store = useStore() | ||
|
||
const pollEditorRef = ref(null) | ||
|
||
const showPollEditor = ref(false) | ||
const showPollDraftHandler = ref(false) | ||
|
||
const token = computed(() => store.getters.getConversationSettingsToken() || store.getters.getToken()) | ||
const canCreatePollDrafts = computed(() => { | ||
return hasTalkFeature(token.value, 'talk-polls-drafts') && store.getters.isModerator | ||
}) | ||
|
||
onMounted(() => { | ||
EventBus.on('poll-editor-open', openPollEditor) | ||
EventBus.on('poll-drafts-open', openPollDraftHandler) | ||
}) | ||
|
||
onBeforeUnmount(() => { | ||
EventBus.off('poll-editor-open', openPollEditor) | ||
EventBus.off('poll-drafts-open', openPollDraftHandler) | ||
}) | ||
|
||
const openPollDraftHandler = () => { | ||
showPollDraftHandler.value = true | ||
} | ||
|
||
const openPollEditor = ({ id, fromDrafts }: { id: number|null, fromDrafts: boolean }) => { | ||
showPollEditor.value = true | ||
nextTick(() => { | ||
pollEditorRef.value?.fillPollEditorFromDraft(id, fromDrafts) | ||
// Wait for editor to be mounted and filled before unmounting drafts dialog to avoid issues when inserting nodes | ||
showPollDraftHandler.value = false | ||
}) | ||
} | ||
|
||
</script> | ||
|
||
<template> | ||
<div> | ||
<!-- Poll creation dialog --> | ||
<PollEditor v-if="showPollEditor" | ||
ref="pollEditorRef" | ||
:token="token" | ||
@close="showPollEditor = false" /> | ||
<!-- Poll drafts dialog --> | ||
<PollDraftHandler v-if="canCreatePollDrafts && showPollDraftHandler" | ||
:token="token" | ||
:editor-opened="showPollEditor" | ||
@close="showPollDraftHandler = false" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters