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:
-rw-r--r--src/js/components/Actions/ActionChangeView.vue94
-rw-r--r--src/js/components/Actions/ActionCopyMailAdresses.vue88
-rw-r--r--src/js/components/Actions/ActionSortOptions.vue95
-rw-r--r--src/js/components/Actions/ActionSubscribe.vue87
-rw-r--r--src/js/components/Actions/ActionToggleSidebar.vue73
-rw-r--r--src/js/components/Base/ButtonDiv.vue28
-rw-r--r--src/js/components/Options/OptionsText.vue6
-rw-r--r--src/js/components/VoteTable/VoteTable.vue15
-rw-r--r--src/js/store/modules/options.js14
-rw-r--r--src/js/store/modules/settings.js75
-rw-r--r--src/js/views/Vote.vue138
11 files changed, 570 insertions, 143 deletions
diff --git a/src/js/components/Actions/ActionChangeView.vue b/src/js/components/Actions/ActionChangeView.vue
new file mode 100644
index 00000000..43c6c195
--- /dev/null
+++ b/src/js/components/Actions/ActionChangeView.vue
@@ -0,0 +1,94 @@
+<!--
+ - @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
+ -
+ - @author René Gieling <github@dartcafe.de>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div class="action change-view">
+ <ButtonDiv v-if="buttonMode"
+ :title="caption"
+ simple
+ :icon="icon"
+ @click="clickAction()" />
+ <Actions v-else>
+ <ActionButton :icon="icon" @click="clickAction()">
+ {{ caption }}
+ </ActionButton>
+ </Actions>
+ </div>
+</template>
+
+<script>
+import { mapState, mapGetters } from 'vuex'
+import { Actions, ActionButton } from '@nextcloud/vue'
+import ButtonDiv from '../Base/ButtonDiv'
+import { emit } from '@nextcloud/event-bus'
+
+export default {
+ name: 'ActionChangeView',
+
+ components: {
+ Actions,
+ ActionButton,
+ ButtonDiv,
+ },
+
+ props: {
+ buttonMode: {
+ type: Boolean,
+ default: false,
+ },
+ },
+
+ computed: {
+ ...mapState({
+ pollType: state => state.poll.type,
+ }),
+
+ ...mapGetters({
+ viewMode: 'settings/viewMode',
+ }),
+
+ caption() {
+ if (this.viewMode === 'table-view') {
+ return t('polls', 'Switch to list view')
+ } else {
+ return t('polls', 'Switch to table view')
+ }
+ },
+
+ icon() {
+ if (this.viewMode === 'table-view') {
+ return 'icon-list-view'
+ } else {
+ return 'icon-table-view'
+ }
+ },
+ },
+
+ methods: {
+
+ clickAction() {
+ emit('transitions-off', 500)
+ this.$store.dispatch('settings/changeView')
+ },
+ },
+}
+</script>
diff --git a/src/js/components/Actions/ActionCopyMailAdresses.vue b/src/js/components/Actions/ActionCopyMailAdresses.vue
new file mode 100644
index 00000000..1743f0c1
--- /dev/null
+++ b/src/js/components/Actions/ActionCopyMailAdresses.vue
@@ -0,0 +1,88 @@
+<!--
+ - @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
+ -
+ - @author René Gieling <github@dartcafe.de>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div class="action copy-mail-adresses">
+ <ButtonDiv v-if="buttonMode"
+ :title="caption"
+ simple
+ :icon="icon"
+ @click="clickAction()" />
+ <Actions v-else>
+ <ActionButton :icon="icon" @click="clickAction()">
+ {{ caption }}
+ </ActionButton>
+ </Actions>
+ </div>
+</template>
+
+<script>
+import { Actions, ActionButton } from '@nextcloud/vue'
+import ButtonDiv from '../Base/ButtonDiv'
+import { mapGetters } from 'vuex'
+import { showSuccess, showError } from '@nextcloud/dialogs'
+
+export default {
+ name: 'ActionCopyMailAdresses',
+
+ components: {
+ Actions,
+ ActionButton,
+ ButtonDiv,
+ },
+
+ props: {
+ buttonMode: {
+ type: Boolean,
+ default: false,
+ },
+ },
+
+ data() {
+ return {
+ icon: 'icon-clippy',
+ }
+ },
+
+ computed: {
+ ...mapGetters({
+ participantsVoted: 'poll/participantsVoted',
+ }),
+
+ caption() {
+ return n('polls', '%n Participant', '%n Participants', this.participantsVoted.length)
+ },
+ },
+ methods: {
+
+ async clickAction() {
+ try {
+ const response = await this.$store.dispatch('poll/getParticipantsEmailAddresses')
+ await this.$copyText(response.data)
+ showSuccess(t('polls', 'Link copied to clipboard'))
+ } catch {
+ showError(t('polls', 'Error while copying link to clipboard'))
+ }
+ },
+ },
+}
+</script>
diff --git a/src/js/components/Actions/ActionSortOptions.vue b/src/js/components/Actions/ActionSortOptions.vue
new file mode 100644
index 00000000..ef36fd16
--- /dev/null
+++ b/src/js/components/Actions/ActionSortOptions.vue
@@ -0,0 +1,95 @@
+<!--
+ - @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
+ -
+ - @author René Gieling <github@dartcafe.de>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div class="action sort-options">
+ <ButtonDiv v-if="buttonMode"
+ :title="caption"
+ simple
+ :icon="icon"
+ @click="clickAction()" />
+ <Actions v-else>
+ <ActionButton :icon="icon" @click="clickAction()">
+ {{ caption }}
+ </ActionButton>
+ </Actions>
+ </div>
+</template>
+
+<script>
+import { mapState, mapMutations } from 'vuex'
+import { Actions, ActionButton } from '@nextcloud/vue'
+import ButtonDiv from '../Base/ButtonDiv'
+
+export default {
+ name: 'ActionSortOptions',
+
+ components: {
+ Actions,
+ ActionButton,
+ ButtonDiv,
+ },
+ props: {
+ buttonMode: {
+ type: Boolean,
+ default: false,
+ },
+ },
+
+ computed: {
+ ...mapState({
+ isRanked: state => state.options.ranked,
+ pollType: state => state.poll.type,
+ }),
+
+ caption() {
+ if (this.isRanked) {
+ if (this.pollType === 'datePoll') {
+ return t('polls', 'Date order')
+ } else {
+ return t('polls', 'Original order')
+ }
+ } else {
+ return t('polls', 'Ranked order')
+ }
+ },
+
+ icon() {
+ if (this.isRanked) {
+ if (this.pollType === 'datePoll') {
+ return 'icon-calendar-000'
+ } else {
+ return 'icon-toggle-filelist'
+ }
+ } else {
+ return 'icon-quota'
+ }
+ },
+ },
+
+ methods: {
+ ...mapMutations({
+ clickAction: 'options/setRankOrder',
+ }),
+ },
+}
+</script>
diff --git a/src/js/components/Actions/ActionSubscribe.vue b/src/js/components/Actions/ActionSubscribe.vue
new file mode 100644
index 00000000..63cc96ad
--- /dev/null
+++ b/src/js/components/Actions/ActionSubscribe.vue
@@ -0,0 +1,87 @@
+<!--
+ - @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
+ -
+ - @author René Gieling <github@dartcafe.de>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div class="action change-view">
+ <ButtonDiv v-if="buttonMode"
+ :title="caption"
+ simple
+ :icon="icon"
+ @click="clickAction()" />
+ <Actions v-else>
+ <ActionButton :icon="icon" @click="clickAction()">
+ {{ caption }}
+ </ActionButton>
+ </Actions>
+ </div>
+</template>
+
+<script>
+import { Actions, ActionButton } from '@nextcloud/vue'
+import { mapState } from 'vuex'
+import ButtonDiv from '../Base/ButtonDiv'
+
+export default {
+ name: 'ActionChangeView',
+
+ components: {
+ Actions,
+ ActionButton,
+ ButtonDiv,
+ },
+
+ props: {
+ buttonMode: {
+ type: Boolean,
+ default: false,
+ },
+ },
+
+ computed: {
+ ...mapState({
+ subscribed: state => state.subscription.subscribed,
+ }),
+
+ caption() {
+ if (this.subscribed) {
+ return t('polls', 'Unsubscribe')
+ } else {
+ return t('polls', 'Subscribe')
+ }
+ },
+
+ icon() {
+ if (this.subscribed) {
+ return 'icon-polls-confirmed'
+ } else {
+ return 'icon-polls-unconfirmed'
+ }
+ },
+ },
+
+ methods: {
+ async clickAction() {
+ await this.$store.dispatch('subscription/update', !this.subscribed)
+ },
+ },
+}
+</script>
diff --git a/src/js/components/Actions/ActionToggleSidebar.vue b/src/js/components/Actions/ActionToggleSidebar.vue
new file mode 100644
index 00000000..37022d85
--- /dev/null
+++ b/src/js/components/Actions/ActionToggleSidebar.vue
@@ -0,0 +1,73 @@
+<!--
+ - @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
+ -
+ - @author René Gieling <github@dartcafe.de>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div class="action change-view">
+ <ButtonDiv v-if="buttonMode"
+ :title="caption"
+ simple
+ :icon="icon"
+ @click="clickAction()" />
+ <Actions v-else>
+ <ActionButton :icon="icon" @click="clickAction()">
+ {{ caption }}
+ </ActionButton>
+ </Actions>
+ </div>
+</template>
+
+<script>
+import { Actions, ActionButton } from '@nextcloud/vue'
+import ButtonDiv from '../Base/ButtonDiv'
+import { emit } from '@nextcloud/event-bus'
+
+export default {
+ name: 'ActionChangeView',
+
+ components: {
+ Actions,
+ ActionButton,
+ ButtonDiv,
+ },
+
+ props: {
+ buttonMode: {
+ type: Boolean,
+ default: false,
+ },
+ },
+
+ data() {
+ return {
+ caption: t('polls', 'Toggle Sidebar'),
+ icon: 'icon-menu-sidebar',
+ }
+ },
+
+ methods: {
+
+ clickAction() {
+ emit('toggle-sidebar')
+ },
+ },
+}
+</script>
diff --git a/src/js/components/Base/ButtonDiv.vue b/src/js/components/Base/ButtonDiv.vue
index 5d92a2dc..116e5fee 100644
--- a/src/js/components/Base/ButtonDiv.vue
+++ b/src/js/components/Base/ButtonDiv.vue
@@ -42,6 +42,10 @@ export default {
type: Boolean,
default: false,
},
+ simple: {
+ type: Boolean,
+ default: false,
+ },
tag: {
type: String,
default: 'button',
@@ -68,6 +72,8 @@ export default {
buttonStyle() {
if (this.submit) {
return 'submit'
+ } else if (this.simple) {
+ return 'simple'
} else {
return 'button'
}
@@ -77,16 +83,32 @@ export default {
</script>
<style lang="scss" scoped>
+ .withIcon {
+ padding-left: 34px;
+ background-position: 12px center;
+ }
+
.button {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
+ }
+ .simple {
+ border: none;
+ background-color: transparent;
+ text-align: left;
+ border-radius: 0;
+ opacity: 0.7;
+ text-align: left;
+ cursor: pointer;
&.withIcon {
- padding-left: 34px;
- background-position: 12px center;
+ padding-left: 32px;
+ background-position: 0 center;
+ }
+ &:hover {
+ background-color: var(--color-background-dark)
}
-
}
.submit {
diff --git a/src/js/components/Options/OptionsText.vue b/src/js/components/Options/OptionsText.vue
index 10c23726..51e4eed5 100644
--- a/src/js/components/Options/OptionsText.vue
+++ b/src/js/components/Options/OptionsText.vue
@@ -23,9 +23,9 @@
<template>
<div>
<ConfigBox v-if="countOptions" :title="t('polls', 'Available Options')" icon-class="icon-toggle-filelist">
- <draggable v-model="sortOptions">
+ <draggable v-model="reOrderedOptions">
<transition-group>
- <OptionItem v-for="(option) in sortOptions"
+ <OptionItem v-for="(option) in reOrderedOptions"
:key="option.id"
:option="option"
:draggable="true">
@@ -98,7 +98,7 @@ export default {
countOptions: 'options/count',
}),
- sortOptions: {
+ reOrderedOptions: {
get() {
return this.options
},
diff --git a/src/js/components/VoteTable/VoteTable.vue b/src/js/components/VoteTable/VoteTable.vue
index c151120c..d16e98eb 100644
--- a/src/js/components/VoteTable/VoteTable.vue
+++ b/src/js/components/VoteTable/VoteTable.vue
@@ -41,7 +41,7 @@
</div>
<transition-group name="list" tag="div" class="vote-table__votes">
- <div v-for="(option) in rankedOptions" :key="option.id" :class="['vote-column', { 'confirmed' : option.confirmed && closed }]">
+ <div v-for="(option) in options" :key="option.id" :class="['vote-column', { 'confirmed' : option.confirmed && closed }]">
<VoteTableHeaderItem :option="option" :view-mode="viewMode" />
<Confirmation v-if="option.confirmed && closed" :option="option" />
@@ -81,7 +81,7 @@
import { mapState, mapGetters } from 'vuex'
import { showSuccess } from '@nextcloud/dialogs'
import { Actions, ActionButton, Modal } from '@nextcloud/vue'
-import orderBy from 'lodash/orderBy'
+import ButtonDiv from '../Base/ButtonDiv'
import CalendarPeek from '../Calendar/CalendarPeek'
import Counter from '../Options/Counter'
import Confirmation from '../Options/Confirmation'
@@ -95,6 +95,7 @@ export default {
components: {
Actions,
ActionButton,
+ ButtonDiv,
CalendarPeek,
Counter,
Confirmation,
@@ -111,10 +112,6 @@ export default {
type: String,
default: 'table-view',
},
- ranked: {
- type: Boolean,
- default: false,
- },
},
data() {
@@ -130,18 +127,15 @@ export default {
poll: state => state.poll,
share: state => state.share,
settings: state => state.settings.user,
- options: state => state.options.list,
}),
...mapGetters({
hideResults: 'poll/hideResults',
closed: 'poll/closed',
participants: 'poll/participants',
+ options: 'options/rankedOptions',
}),
- rankedOptions() {
- return orderBy(this.options, this.ranked ? 'rank' : 'order', 'asc')
- },
},
methods: {
@@ -161,7 +155,6 @@ export default {
</script>
<style lang="scss">
-
.vote-table {
display: flex;
flex: 1;
diff --git a/src/js/store/modules/options.js b/src/js/store/modules/options.js
index 84017151..9ea54ae5 100644
--- a/src/js/store/modules/options.js
+++ b/src/js/store/modules/options.js
@@ -22,10 +22,12 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
+import orderBy from 'lodash/orderBy'
const defaultOptions = () => {
return {
list: [],
+ ranked: false,
}
}
@@ -49,6 +51,14 @@ const mutations = {
state.list = payload.options
},
+ setRankOrder(state, payload) {
+ if (payload) {
+ state.ranked = payload
+ } else {
+ state.ranked = !state.ranked
+ }
+ },
+
delete(state, payload) {
state.list = state.list.filter(option => {
return option.id !== payload.option.id
@@ -81,6 +91,10 @@ const getters = {
return state.list.length
},
+ rankedOptions: (state) => {
+ return orderBy(state.list, state.ranked ? 'rank' : 'order', 'asc')
+ },
+
confirmed: state => {
return state.list.filter(option => {
return option.confirmed > 0
diff --git a/src/js/store/modules/settings.js b/src/js/store/modules/settings.js
index 53d3441d..f71802ab 100644
--- a/src/js/store/modules/settings.js
+++ b/src/js/store/modules/settings.js
@@ -36,6 +36,10 @@ const defaultSettings = () => {
defaultViewTextPoll: 'list-view',
defaultViewDatePoll: 'table-view',
},
+ session: {
+ manualViewDatePoll: '',
+ manualViewTextPoll: '',
+ },
availableCalendars: [],
viewModes: [
'list-view',
@@ -71,12 +75,65 @@ const mutations = {
state.user[key] = payload[key]
})
},
+
setCalendars(state, payload) {
state.availableCalendars = payload.calendars
},
+
addCheckCalendar(state, payload) {
state.user.checkCalendars.push(payload.calendar.key)
},
+
+ setViewDatePoll(state, payload) {
+ state.session.manualViewDatePoll = payload
+ },
+ setViewTextPoll(state, payload) {
+ state.session.manualViewTextPoll = payload
+ },
+}
+
+const getters = {
+ viewTextPoll(state) {
+ if (state.session.manualViewTextPoll) {
+ return state.session.manualViewTextPoll
+ } else {
+ if (window.innerWidth > 480) {
+ return state.user.defaultViewTextPoll
+ } else {
+ return 'list-view'
+ }
+ }
+ },
+
+ getNextViewMode(state, getters) {
+ if (state.viewModes.indexOf(getters.viewMode) < 0) {
+ return state.viewModes[1]
+ } else {
+ return state.viewModes[(state.viewModes.indexOf(getters.viewMode) + 1) % state.viewModes.length]
+ }
+ },
+
+ viewDatePoll(state) {
+ if (state.session.manualViewDatePoll) {
+ return state.session.manualViewDatePoll
+ } else {
+ if (window.innerWidth > 480) {
+ return state.user.defaultViewDatePoll
+ } else {
+ return 'list-view'
+ }
+ }
+ },
+
+ viewMode(state, getters, rootState) {
+ if (rootState.poll.type === 'textPoll') {
+ return getters.viewTextPoll
+ } else if (rootState.poll.type === 'datePoll') {
+ return getters.viewDatePoll
+ } else {
+ return 'table-view'
+ }
+ },
}
const actions = {
@@ -102,6 +159,22 @@ const actions = {
}
},
+ changeView(context) {
+ if (context.rootState.poll.type === 'datePoll') {
+ if (context.state.manualViewDatePoll) {
+ context.commit('setViewDatePoll', '')
+ } else {
+ context.commit('setViewDatePoll', context.getters.getNextViewMode)
+ }
+ } else if (context.rootState.poll.type === 'textPoll') {
+ if (context.state.manualViewTextPoll) {
+ context.commit('setViewTextPoll', '')
+ } else {
+ context.commit('setViewTextPoll', context.getters.getNextViewMode)
+ }
+ }
+ },
+
async write(context) {
const endPoint = 'apps/polls/preferences/write'
try {
@@ -121,4 +194,4 @@ const actions = {
},
}
-export default { namespaced, state, mutations, actions }
+export default { namespaced, state, mutations, getters, actions }
diff --git a/src/js/views/Vote.vue b/src/js/views/Vote.vue
index 25548cfb..2a3c9947 100644
--- a/src/js/views/Vote.vue
+++ b/src/js/views/Vote.vue
@@ -24,21 +24,9 @@
<AppContent :class="[{ closed: closed }, poll.type]">
<div class="header-actions">
<PollInformation />
- <Actions>
- <ActionButton :icon="sortIcon" @click="ranked = !ranked">
- {{ orderCaption }}
- </ActionButton>
- </Actions>
- <Actions>
- <ActionButton :icon="toggleViewIcon" @click="toggleView()">
- {{ viewCaption }}
- </ActionButton>
- </Actions>
- <Actions>
- <ActionButton v-if="acl.allowEdit || poll.allowComment" icon="icon-menu-sidebar" @click="toggleSideBar()">
- {{ t('polls', 'Toggle Sidebar') }}
- </ActionButton>
- </Actions>
+ <ActionSortOptions />
+ <ActionChangeView />
+ <ActionToggleSidebar v-if="acl.allowEdit || poll.allowComment" />
</div>
<div class="area__header">
<h2 class="title">
@@ -61,7 +49,7 @@
</div>
<div class="area__main" :class="viewMode">
- <VoteTable v-show="options.length" :view-mode="viewMode" :ranked="ranked" />
+ <VoteTable v-show="options.length" :view-mode="viewMode" />
<EmptyContent v-if="!options.length" icon="icon-toggle-filelist">
{{ t('polls', 'No vote options available') }}
@@ -91,7 +79,7 @@
<script>
import { showError, showSuccess } from '@nextcloud/dialogs'
import { mapState, mapGetters } from 'vuex'
-import { Actions, ActionButton, AppContent, EmptyContent } from '@nextcloud/vue'
+import { AppContent, EmptyContent } from '@nextcloud/vue'
import { getCurrentUser } from '@nextcloud/auth'
import { emit } from '@nextcloud/event-bus'
import moment from '@nextcloud/moment'
@@ -101,12 +89,16 @@ import LoadingOverlay from '../components/Base/LoadingOverlay'
import PollInformation from '../components/Poll/PollInformation'
import PublicRegisterModal from '../components/Poll/PublicRegisterModal'
import VoteTable from '../components/VoteTable/VoteTable'
+import ActionSortOptions from '../components/Actions/ActionSortOptions'
+import ActionChangeView from '../components/Actions/ActionChangeView'
+import ActionToggleSidebar from '../components/Actions/ActionToggleSidebar'
export default {
name: 'Vote',
components: {
- Actions,
- ActionButton,
+ ActionChangeView,
+ ActionSortOptions,
+ ActionToggleSidebar,
AppContent,
Badge,
MarkUpDescription,
@@ -121,9 +113,6 @@ export default {
return {
delay: 50,
isLoading: false,
- manualViewDatePoll: '',
- manualViewTextPoll: '',
- ranked: false,
voteSaved: false,
}
},
@@ -132,53 +121,20 @@ export default {
...mapState({
poll: state => state.poll,
acl: state => state.poll.acl,
- options: state => state.options.list,
share: state => state.share,
settings: state => state.settings,
}),
...mapGetters({
+ options: 'options/rankedOptions',
closed: 'poll/closed',
+ viewMode: 'settings/viewMode',
}),
showEmailEdit() {
return ['email', 'contact', 'external'].includes(this.share.type)
},
- viewTextPoll() {
- if (this.manualViewTextPoll) {
- return this.manualViewTextPoll
- } else {
- if (window.innerWidth > 480) {
- return this.settings.user.defaultViewTextPoll
- } else {
- return 'list-view'
- }
- }
- },
-
- viewDatePoll() {
- if (this.manualViewDatePoll) {
- return this.manualViewDatePoll
- } else {
- if (window.innerWidth > 480) {
- return this.settings.user.defaultViewDatePoll
- } else {
- return 'list-view'
- }
- }
- },
-
- viewMode() {
- if (this.poll.type === 'textPoll') {
- return this.viewTextPoll
- } else if (this.poll.type === 'datePoll') {
- return this.viewDatePoll
- } else {
- return 'table-view'
- }
- },
-
windowTitle() {
return t('polls', 'Polls') + ' - ' + this.poll.title
},
@@ -207,25 +163,6 @@ export default {
}
},
- viewCaption() {
- if (this.viewMode === 'table-view') {
- return t('polls', 'Switch to list view')
- } else {
- return t('polls', 'Switch to table view')
- }
- },
- orderCaption() {
- if (this.ranked) {
- if (this.poll.type === 'datePoll') {
- return t('polls', 'Date order')
- } else {
- return t('polls', 'Original order')
- }
- } else {
- return t('polls', 'Ranked order')
- }
- },
-
showRegisterModal() {
return (this.$route.name === 'publicVote'
&& ['public', 'email', 'contact'].includes(this.share.type)
@@ -234,26 +171,6 @@ export default {
)
},
- sortIcon() {
- if (this.ranked) {
- if (this.poll.type === 'datePoll') {
- return 'icon-calendar-000'
- } else {
- return 'icon-toggle-filelist'
- }
- } else {
- return 'icon-quota'
- }
- },
-
- toggleViewIcon() {
- if (this.viewMode === 'table-view') {
- return 'icon-list-view'
- } else {
- return 'icon-table-view'
- }
- },
-
},
created() {
@@ -289,35 +206,6 @@ export default {
emit('toggle-sidebar', { open: true, activeTab: 'options' })
},
- getNextViewMode() {
- if (this.settings.viewModes.indexOf(this.viewMode) < 0) {
- return this.settings.viewModes[1]
- } else {
- return this.settings.viewModes[(this.settings.viewModes.indexOf(this.viewMode) + 1) % this.settings.viewModes.length]
- }
- },
-
- toggleSideBar() {
- emit('toggle-sidebar')
- },
-
- toggleView() {
- emit('transitions-off', 500)
- if (this.poll.type === 'datePoll') {
- if (this.manualViewDatePoll) {
- this.manualViewDatePoll = ''
- } else {
- this.manualViewDatePoll = this.getNextViewMode()
- }
- } else if (this.poll.type === 'textPoll') {
- if (this.manualViewTextPoll) {
- this.manualViewTextPoll = ''
- } else {
- this.manualViewTextPoll = this.getNextViewMode()
- }
- }
- },
-
async submitEmailAddress(emailAddress) {
try {
await this.$store.dispatch('share/updateEmailAddress', { emailAddress: emailAddress })