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>2021-03-22 09:03:57 +0300
committerdartcafe <github@dartcafe.de>2021-03-22 09:03:57 +0300
commitc165ee20f9f840087fa56346d716e41163c262fa (patch)
tree78bceba699d4be9cf2e3db830c21f6bde8aa16a3 /src/js/components/Actions
parentcfa138e12f20994543bc6aca809847ad636a79c8 (diff)
drill down actions to components and move some logic to store
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/components/Actions')
-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
5 files changed, 437 insertions, 0 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>