diff options
Diffstat (limited to 'src/js/store/modules/poll.js')
-rw-r--r-- | src/js/store/modules/poll.js | 97 |
1 files changed, 39 insertions, 58 deletions
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 = { |