Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-12-07 00:54:42 +0300
committerdartcafe <github@dartcafe.de>2020-12-07 00:54:42 +0300
commit4b72db6c82552572ac90381d8e250c6f70b38d2b (patch)
tree8f6fa54628a12550df630572828e5a90bad18b17 /src/js/views/PollList.vue
parent9f7537b6b526d5ef56a742dc354b12d0531b785e (diff)
Adding admin section
Diffstat (limited to 'src/js/views/PollList.vue')
-rw-r--r--src/js/views/PollList.vue101
1 files changed, 93 insertions, 8 deletions
diff --git a/src/js/views/PollList.vue b/src/js/views/PollList.vue
index 69738950..dcca1fcd 100644
--- a/src/js/views/PollList.vue
+++ b/src/js/views/PollList.vue
@@ -45,11 +45,42 @@
class="poll-list__list">
<PollItem key="0" :header="true"
:sort="sort" :reverse="reverse" @sort-list="setSort($event)" />
- <li is="PollItem"
- v-for="(poll, index) in sortedList"
- :key="poll.id"
- :poll="poll"
- @clone-poll="callPoll(index, poll, 'clone')" />
+
+ <PollItem v-for="(poll) in sortedList" :key="poll.id" :poll="poll"
+ @goto-poll="gotoPoll(poll.id)"
+ @load-poll="loadPoll(poll.id)">
+ <template #actions>
+ <Actions :force-menu="true">
+ <ActionButton icon="icon-add"
+ :close-after-click="true"
+ @click="clonePoll(poll.id)">
+ {{ t('polls', 'Clone poll') }}
+ </ActionButton>
+
+ <ActionButton v-if="poll.allowEdit && !poll.deleted"
+ icon="icon-delete"
+ :close-after-click="true"
+ @click="switchDeleted(poll.id)">
+ {{ t('polls', 'Delete poll') }}
+ </ActionButton>
+
+ <ActionButton v-if="poll.allowEdit && poll.deleted"
+ icon="icon-history"
+ :close-after-click="true"
+ @click="switchDeleted(poll.id)">
+ {{ t('polls', 'Restore poll') }}
+ </ActionButton>
+
+ <ActionButton v-if="poll.allowEdit && poll.deleted"
+ icon="icon-delete"
+ class="danger"
+ :close-after-click="true"
+ @click="deletePermanently(poll.id)">
+ {{ t('polls', 'Delete poll permanently') }}
+ </ActionButton>
+ </Actions>
+ </template>
+ </PollItem>
</transition-group>
</div>
<LoadingOverlay v-if="isLoading" />
@@ -57,18 +88,21 @@
</template>
<script>
-import { AppContent, EmptyContent } from '@nextcloud/vue'
-import PollItem from '../components/PollList/PollItem'
import { mapGetters } from 'vuex'
import sortBy from 'lodash/sortBy'
-import LoadingOverlay from '../components/Base/LoadingOverlay'
+import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
+import { Actions, ActionButton, AppContent, EmptyContent } from '@nextcloud/vue'
+import PollItem from '../components/PollList/PollItem'
+import LoadingOverlay from '../components/Base/LoadingOverlay'
export default {
name: 'PollList',
components: {
AppContent,
+ Actions,
+ ActionButton,
LoadingOverlay,
PollItem,
EmptyContent,
@@ -156,6 +190,24 @@ export default {
},
methods: {
+ gotoPoll(pollId) {
+ this.$router
+ .push({ name: 'vote', params: { id: pollId } })
+ },
+
+ loadPoll(pollId) {
+ this.$store
+ .dispatch({ type: 'poll/get', pollId: pollId })
+ .then(() => {
+ emit('toggle-sidebar', { open: true })
+ })
+ .catch((error) => {
+ console.error(error)
+ showError(t('polls', 'Error loading poll'))
+ })
+
+ },
+
refreshView() {
window.document.title = t('polls', 'Polls') + ' - ' + this.title
if (!this.filteredPolls(this.$route.params.type).find(poll => {
@@ -183,6 +235,39 @@ export default {
},
})
},
+
+ switchDeleted(pollId) {
+ this.$store
+ .dispatch('poll/switchDeleted', { pollId: pollId })
+ .then(() => {
+ emit('update-polls')
+ })
+ .catch(() => {
+ showError(t('polls', 'Error deleting poll.'))
+ })
+ },
+
+ deletePermanently(pollId) {
+ this.$store
+ .dispatch('poll/delete', { pollId: pollId })
+ .then(() => {
+ emit('update-polls')
+ })
+ .catch(() => {
+ showError(t('polls', 'Error deleting poll.'))
+ })
+ },
+
+ clonePoll(pollId) {
+ this.$store
+ .dispatch('poll/clone', { pollId: pollId })
+ .then(() => {
+ emit('update-polls')
+ })
+ .catch(() => {
+ showError(t('polls', 'Error cloning poll.'))
+ })
+ },
},
}
</script>