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-04-19 00:01:15 +0300
committerdartcafe <github@dartcafe.de>2021-04-19 00:01:15 +0300
commit52d0ea73368123a37e7cff11810d1fcced2ecf70 (patch)
tree243b38f44175c2b8b2882bd0d195b06388769723 /src/js/store
parent43e516fd48128c94b045c83674fe5970e61cee2d (diff)
arrow-body-style
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/store')
-rw-r--r--src/js/store/modules/comments.js16
-rw-r--r--src/js/store/modules/options.js42
-rw-r--r--src/js/store/modules/poll.js97
-rw-r--r--src/js/store/modules/pollsAdmin.js4
-rw-r--r--src/js/store/modules/settings.js46
-rw-r--r--src/js/store/modules/share.js22
-rw-r--r--src/js/store/modules/shares.js26
-rw-r--r--src/js/store/modules/subModules/acl.js38
-rw-r--r--src/js/store/modules/subscription.js8
-rw-r--r--src/js/store/modules/votes.js26
10 files changed, 123 insertions, 202 deletions
diff --git a/src/js/store/modules/comments.js b/src/js/store/modules/comments.js
index 59283ae8..a980067c 100644
--- a/src/js/store/modules/comments.js
+++ b/src/js/store/modules/comments.js
@@ -24,11 +24,9 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultComments = () => {
- return {
- list: [],
- }
-}
+const defaultComments = () => ({
+ list: [],
+})
const state = defaultComments()
@@ -49,16 +47,12 @@ const mutations = {
},
delete(state, payload) {
- state.list = state.list.filter((comment) => {
- return comment.id !== payload.comment.id
- })
+ state.list = state.list.filter((comment) => comment.id !== payload.comment.id)
},
}
const getters = {
- count: (state) => {
- return state.list.length
- },
+ count: (state) => state.list.length,
}
const actions = {
diff --git a/src/js/store/modules/options.js b/src/js/store/modules/options.js
index ec081542..9f04779f 100644
--- a/src/js/store/modules/options.js
+++ b/src/js/store/modules/options.js
@@ -24,12 +24,10 @@ import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import orderBy from 'lodash/orderBy'
-const defaultOptions = () => {
- return {
- list: [],
- ranked: false,
- }
-}
+const defaultOptions = () => ({
+ list: [],
+ ranked: false,
+})
const state = defaultOptions()
@@ -60,23 +58,17 @@ const mutations = {
},
delete(state, payload) {
- state.list = state.list.filter((option) => {
- return option.id !== payload.option.id
- })
+ state.list = state.list.filter((option) => option.id !== payload.option.id)
},
confirm(state, payload) {
- const index = state.list.findIndex((option) => {
- return option.id === payload.option.id
- })
+ const index = state.list.findIndex((option) => option.id === payload.option.id)
state.list[index].confirmed = !state.list[index].confirmed
},
setItem(state, payload) {
- const index = state.list.findIndex((option) => {
- return option.id === payload.option.id
- })
+ const index = state.list.findIndex((option) => option.id === payload.option.id)
if (index < 0) {
state.list.push(payload.option)
@@ -87,25 +79,13 @@ const mutations = {
}
const getters = {
- count: (state) => {
- return state.list.length
- },
+ count: (state) => state.list.length,
- rankedOptions: (state) => {
- return orderBy(state.list, state.ranked ? 'rank' : 'order', 'asc')
- },
+ rankedOptions: (state) => orderBy(state.list, state.ranked ? 'rank' : 'order', 'asc'),
- proposalsExist: (state) => {
- return !!state.list.filter((option) => {
- return option.owner
- }).length
- },
+ proposalsExist: (state) => !!state.list.filter((option) => option.owner).length,
- confirmed: (state) => {
- return state.list.filter((option) => {
- return option.confirmed > 0
- })
- },
+ confirmed: (state) => state.list.filter((option) => option.confirmed > 0),
}
const actions = {
diff --git a/src/js/store/modules/poll.js b/src/js/store/modules/poll.js
index 656158f9..2528ba74 100644
--- a/src/js/store/modules/poll.js
+++ b/src/js/store/modules/poll.js
@@ -27,31 +27,29 @@ import { generateUrl } from '@nextcloud/router'
import acl from './subModules/acl.js'
import { uniqueArrayOfObjects } from '../../helpers/arrayHelper.js'
-const defaultPoll = () => {
- return {
- id: 0,
- type: 'datePoll',
- title: '',
- description: '',
- descriptionSafe: '',
- owner: '',
- created: 0,
- expire: 0,
- deleted: 0,
- access: 'hidden',
- anonymous: 0,
- allowComment: 0,
- allowMaybe: 0,
- allowProposals: 'disallow',
- proposalsExpire: 0,
- voteLimit: 0,
- optionLimit: 0,
- showResults: 'always',
- adminAccess: 0,
- important: 0,
- hideBookedUp: 0,
- }
-}
+const defaultPoll = () => ({
+ id: 0,
+ type: 'datePoll',
+ title: '',
+ description: '',
+ descriptionSafe: '',
+ owner: '',
+ created: 0,
+ expire: 0,
+ deleted: 0,
+ access: 'hidden',
+ anonymous: 0,
+ allowComment: 0,
+ allowMaybe: 0,
+ allowProposals: 'disallow',
+ proposalsExpire: 0,
+ voteLimit: 0,
+ optionLimit: 0,
+ showResults: 'always',
+ adminAccess: 0,
+ important: 0,
+ hideBookedUp: 0,
+})
const state = defaultPoll()
@@ -95,37 +93,23 @@ const getters = {
},
- proposalsAllowed: (state) => {
- return (state.allowProposals === 'allow' || state.allowProposals === 'review')
- },
+ proposalsAllowed: (state) => (state.allowProposals === 'allow' || state.allowProposals === 'review'),
- proposalsOpen: (state, getters) => {
- return getters.proposalsAllowed && !getters.proposalsExpired
- },
+ proposalsOpen: (state, getters) => getters.proposalsAllowed && !getters.proposalsExpired,
- proposalsExpired: (state, getters) => {
- return getters.proposalsAllowed && state.proposalsExpire && moment.unix(state.proposalsExpire).diff() < 0
- },
+ proposalsExpired: (state, getters) => getters.proposalsAllowed && state.proposalsExpire && moment.unix(state.proposalsExpire).diff() < 0,
- proposalsExpirySet: (state, getters) => {
- return getters.proposalsAllowed && state.proposalsExpire
- },
+ proposalsExpirySet: (state, getters) => getters.proposalsAllowed && state.proposalsExpire,
- proposalsExpireRelative: (state) => {
- return moment.unix(state.proposalsExpire).fromNow()
- },
+ proposalsExpireRelative: (state) => moment.unix(state.proposalsExpire).fromNow(),
- proposalsOptions: () => {
- return [
- { value: 'disallow', label: t('polls', 'Disallow proposals') },
- { value: 'allow', label: t('polls', 'Allow proposals') },
- // { value: 'review', label: t('polls', 'Allow with review') },
- ]
- },
+ proposalsOptions: () => [
+ { value: 'disallow', label: t('polls', 'Disallow proposals') },
+ { value: 'allow', label: t('polls', 'Allow proposals') },
+ // { value: 'review', label: t('polls', 'Allow with review') },
+ ],
- closed: (state) => {
- return (state.expire > 0 && moment.unix(state.expire).diff() < 0)
- },
+ closed: (state) => (state.expire > 0 && moment.unix(state.expire).diff() < 0),
participants: (state, getters, rootState) => {
const participants = rootState.votes.list.map((item) => ({
@@ -149,14 +133,11 @@ const getters = {
},
- participantsVoted: (state, getters, rootState) => {
- return uniqueArrayOfObjects(rootState.votes.list.map((item) => ({
- userId: item.userId,
- displayName: item.displayName,
- isNoUser: item.isNoUser,
- })))
-
- },
+ participantsVoted: (state, getters, rootState) => uniqueArrayOfObjects(rootState.votes.list.map((item) => ({
+ userId: item.userId,
+ displayName: item.displayName,
+ isNoUser: item.isNoUser,
+ }))),
}
const actions = {
diff --git a/src/js/store/modules/pollsAdmin.js b/src/js/store/modules/pollsAdmin.js
index b85b117d..f90506ab 100644
--- a/src/js/store/modules/pollsAdmin.js
+++ b/src/js/store/modules/pollsAdmin.js
@@ -38,9 +38,7 @@ const mutations = {
}
const getters = {
- filtered: (state) => (filterId) => {
- return state.list
- },
+ filtered: (state) => (filterId) => state.list,
}
const actions = {
diff --git a/src/js/store/modules/settings.js b/src/js/store/modules/settings.js
index 0b6ad4ec..8cffb1ce 100644
--- a/src/js/store/modules/settings.js
+++ b/src/js/store/modules/settings.js
@@ -23,30 +23,28 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultSettings = () => {
- return {
- user: {
- experimental: false,
- calendarPeek: false,
- checkCalendars: [],
- useImage: false,
- imageUrl: '',
- glassyNavigation: false,
- glassySidebar: false,
- defaultViewTextPoll: 'list-view',
- defaultViewDatePoll: 'table-view',
- },
- session: {
- manualViewDatePoll: '',
- manualViewTextPoll: '',
- },
- availableCalendars: [],
- viewModes: [
- 'list-view',
- 'table-view',
- ],
- }
-}
+const defaultSettings = () => ({
+ user: {
+ experimental: false,
+ calendarPeek: false,
+ checkCalendars: [],
+ useImage: false,
+ imageUrl: '',
+ glassyNavigation: false,
+ glassySidebar: false,
+ defaultViewTextPoll: 'list-view',
+ defaultViewDatePoll: 'table-view',
+ },
+ session: {
+ manualViewDatePoll: '',
+ manualViewTextPoll: '',
+ },
+ availableCalendars: [],
+ viewModes: [
+ 'list-view',
+ 'table-view',
+ ],
+})
const state = defaultSettings()
const namespaced = true
diff --git a/src/js/store/modules/share.js b/src/js/store/modules/share.js
index 9fda41e0..860ef460 100644
--- a/src/js/store/modules/share.js
+++ b/src/js/store/modules/share.js
@@ -24,18 +24,16 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultShares = () => {
- return {
- displayName: '',
- id: null,
- invitationSent: 0,
- pollId: null,
- token: '',
- type: '',
- emailAddress: '',
- userId: '',
- }
-}
+const defaultShares = () => ({
+ displayName: '',
+ id: null,
+ invitationSent: 0,
+ pollId: null,
+ token: '',
+ type: '',
+ emailAddress: '',
+ userId: '',
+})
const state = defaultShares()
diff --git a/src/js/store/modules/shares.js b/src/js/store/modules/shares.js
index 3a9b7633..ca08f437 100644
--- a/src/js/store/modules/shares.js
+++ b/src/js/store/modules/shares.js
@@ -24,11 +24,9 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultShares = () => {
- return {
- list: [],
- }
-}
+const defaultShares = () => ({
+ list: [],
+})
const state = defaultShares()
@@ -40,9 +38,7 @@ const mutations = {
},
delete(state, payload) {
- state.list = state.list.filter((share) => {
- return share.id !== payload.share.id
- })
+ state.list = state.list.filter((share) => share.id !== payload.share.id)
},
reset(state) {
@@ -66,22 +62,14 @@ const getters = {
const invitationTypes = ['email', 'external', 'contact']
// sharetype which are active without sending an invitation
const directShareTypes = ['user', 'group']
- return state.list.filter((share) => {
- return (invitationTypes.includes(share.type) && (share.type === 'external' || share.invitationSent)) || directShareTypes.includes(share.type)
- })
+ return state.list.filter((share) => (invitationTypes.includes(share.type) && (share.type === 'external' || share.invitationSent)) || directShareTypes.includes(share.type))
},
- unsentInvitations: (state) => {
- return state.list.filter((share) => {
- return (share.emailAddress || share.type === 'group' || share.type === 'contactGroup' || share.type === 'circle') && !share.invitationSent
- })
- },
+ unsentInvitations: (state) => state.list.filter((share) => (share.emailAddress || share.type === 'group' || share.type === 'contactGroup' || share.type === 'circle') && !share.invitationSent),
public: (state) => {
const invitationTypes = ['public']
- return state.list.filter((share) => {
- return invitationTypes.includes(share.type)
- })
+ return state.list.filter((share) => invitationTypes.includes(share.type))
},
}
diff --git a/src/js/store/modules/subModules/acl.js b/src/js/store/modules/subModules/acl.js
index ecb4028c..fb18bb47 100644
--- a/src/js/store/modules/subModules/acl.js
+++ b/src/js/store/modules/subModules/acl.js
@@ -21,26 +21,24 @@
*
*/
-const defaultAcl = () => {
- return {
- allowComment: false,
- allowEdit: false,
- allowAddOptions: false,
- allowSeeResults: false,
- allowSeeUsernames: false,
- allowSubscribe: false,
- allowView: false,
- allowVote: false,
- displayName: '',
- isOwner: false,
- loggedIn: false,
- pollId: null,
- token: '',
- userHasVoted: false,
- userId: '',
- userIsInvolved: '',
- }
-}
+const defaultAcl = () => ({
+ allowComment: false,
+ allowEdit: false,
+ allowAddOptions: false,
+ allowSeeResults: false,
+ allowSeeUsernames: false,
+ allowSubscribe: false,
+ allowView: false,
+ allowVote: false,
+ displayName: '',
+ isOwner: false,
+ loggedIn: false,
+ pollId: null,
+ token: '',
+ userHasVoted: false,
+ userId: '',
+ userIsInvolved: '',
+})
const state = defaultAcl()
diff --git a/src/js/store/modules/subscription.js b/src/js/store/modules/subscription.js
index abfb895c..cba1e1ee 100644
--- a/src/js/store/modules/subscription.js
+++ b/src/js/store/modules/subscription.js
@@ -24,11 +24,9 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultSubscription = () => {
- return {
- subscribed: false,
- }
-}
+const defaultSubscription = () => ({
+ subscribed: false,
+})
const state = defaultSubscription()
diff --git a/src/js/store/modules/votes.js b/src/js/store/modules/votes.js
index 4eeea28f..a132be78 100644
--- a/src/js/store/modules/votes.js
+++ b/src/js/store/modules/votes.js
@@ -23,11 +23,9 @@
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
-const defaultVotes = () => {
- return {
- list: [],
- }
-}
+const defaultVotes = () => ({
+ list: [],
+})
const state = defaultVotes()
@@ -61,23 +59,13 @@ const mutations = {
const getters = {
- relevant: (state, getters, rootState) => {
- return state.list.filter((vote) => {
- return rootState.options.list.some((option) => {
- return option.pollId === vote.pollId && option.pollOptionText === vote.voteOptionText
- })
- })
- },
+ relevant: (state, getters, rootState) => state.list.filter((vote) => rootState.options.list.some((option) => option.pollId === vote.pollId && option.pollOptionText === vote.voteOptionText)),
- countVotes: (state, getters, rootState) => (answer) => {
- return getters.relevant.filter((vote) => vote.userId === rootState.poll.acl.userId && vote.voteAnswer === answer).length
- },
+ countVotes: (state, getters, rootState) => (answer) => getters.relevant.filter((vote) => vote.userId === rootState.poll.acl.userId && vote.voteAnswer === answer).length,
getVote: (state) => (payload) => {
- const found = state.list.find((vote) => {
- return (vote.userId === payload.userId
- && vote.voteOptionText === payload.option.pollOptionText)
- })
+ const found = state.list.find((vote) => (vote.userId === payload.userId
+ && vote.voteOptionText === payload.option.pollOptionText))
if (found === undefined) {
return {
voteAnswer: '',