Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 1.0 #762

Merged
merged 8 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#list', 'url' => '/list/{pollId}', 'verb' => 'GET'],
['name' => 'page#polls', 'url' => '/vote/{pollId}', 'verb' => 'GET'],
['name' => 'page#list', 'url' => '/list/{id}', 'verb' => 'GET'],
['name' => 'page#polls', 'url' => '/vote/{id}', 'verb' => 'GET'],
['name' => 'page#vote_public', 'url' => '/s/{token}', 'verb' => 'GET'],
['name' => 'page#old_vote_public', 'url' => '/poll/{token}', 'verb' => 'GET'],

['name' => 'subscription#get', 'url' => '/subscription/get/{pollId}', 'verb' => 'GET'],
['name' => 'subscription#set', 'url' => '/subscription/set/', 'verb' => 'POST'],
Expand Down
14 changes: 13 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,19 @@ public function list() {
* @param string $token
* @return PublicTemplateResponse
*/
public function votePublic(/** @scrutinizer ignore-unused */ $token) {
public function votePublic() {
return new PublicTemplateResponse('polls', 'polls.tmpl', [
'urlGenerator' => $this->urlGenerator]);
}

/**
* @PublicPage
* @NoAdminRequired
* @NoCSRFRequired
* @param string $token
* @return PublicTemplateResponse
*/
public function oldVotePublic() {
return new PublicTemplateResponse('polls', 'polls.tmpl', [
'urlGenerator' => $this->urlGenerator]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function write($pollId, $share) {
$newShare->setType($share['type']);
$newShare->setPollId($share['pollId']);
$newShare->setUserId($share['userId']);
$newShare->setUserEmail($share['userEmail']);
$newShare->setUserEmail(isset($share['userEmail']) ? $share['userEmail'] : '' ,);
$newShare->setToken(\OC::$server->getSecureRandom()->generate(
16,
ISecureRandom::CHAR_DIGITS .
Expand Down
13 changes: 9 additions & 4 deletions src/js/components/Base/ParticipantsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@

<template>
<div class="participants-list">
<h2>{{ t('polls','Participants') }}</h2>
<div class="participants">
<userDiv v-for="(participant) in participants"
<h2 v-if="participantsVoted.length">
{{ t('polls','Participants') }}
</h2>
<h2 v-else>
{{ t('polls','No Participants until now') }}
</h2>
<div v-if="participantsVoted.length" class="participants">
<userDiv v-for="(participant) in participantsVoted"
:key="participant"
:hide-names="true"
:user-id="participant"
Expand Down Expand Up @@ -53,7 +58,7 @@ export default {
}),

...mapGetters([
'participants'
'participantsVoted'
])

}
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/Base/PollInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<span v-if="expired">{{ t('polls', 'Voting is no more possible, because this poll expired since %n.', 1, moment.unix(poll.expire).format('LLLL')) }}</span>
<span v-if="!expired && poll.expire && acl.allowVote">{{ t('polls', 'You can place your vote until %n. ', 1, moment.unix(poll.expire).format('LLLL')) }}</span>
<span v-if="poll.anonymous">{{ t('polls', 'The names of other participants are hidden, as this is an anonymous poll. ') }}</span>
<span>{{ n('polls', '%n person participated in this poll until now.', '%n persons participated in this poll until now.', participants.length) }}</span>
<span>{{ n('polls', '%n person participated in this poll until now.', '%n persons participated in this poll until now.', participantsVoted.length) }}</span>
</div>
</template>

Expand All @@ -49,7 +49,7 @@ export default {
}),

...mapGetters([
'participants',
'participantsVoted',
'expired'
])
}
Expand Down
10 changes: 8 additions & 2 deletions src/js/components/Create/CreateDlg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<template lang="html">
<div class="create-dialog">
<h2>{{ t('polls', 'Create new poll') }}</h2>
<input id="pollTitle" v-model="title" type="text"
:placeholder="t('polls', 'Enter Title')">
<input id="pollTitle" ref="pollTitle" v-model="title"
type="text" :placeholder="t('polls', 'Enter Title')" @keyup.enter="confirm">

<div class="config-box">
<label class="title icon-checkmark">
Expand Down Expand Up @@ -101,6 +101,12 @@ export default {
.catch(() => {
OC.Notification.showTemporary(t('polls', 'Error while creating Poll "%n"', 1, this.poll.title), { type: 'error' })
})
},

setFocus() {
this.$nextTick(() => {
this.$refs.pollTitle.focus()
})
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/js/components/Navigation/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<template lang="html">
<AppNavigation>
<AppNavigationNew :text="t('polls', 'Add new Poll')" @click="toggleCreateDlg" />
<CreateDlg v-show="createDlg" @closeCreate="closeCreate()" />
<CreateDlg v-show="createDlg" ref="createDlg" @closeCreate="closeCreate()" />
<ul>
<AppNavigationItem :title="t('polls', 'All polls')" :allow-collapse="true"
icon="icon-folder" :to="{ name: 'list', params: {type: 'all'}}" :open="true">
Expand Down Expand Up @@ -130,6 +130,13 @@ export default {
this.createDlg = false
},

toggleCreateDlg() {
this.createDlg = !this.createDlg
if (this.createDlg) {
this.$refs.createDlg.setFocus()
}
},

clonePoll(pollId) {
this.$store
.dispatch('clonePoll', { pollId: pollId })
Expand All @@ -148,10 +155,6 @@ export default {

},

toggleCreateDlg() {
this.createDlg = !this.createDlg
},

refreshPolls() {
if (this.$route.name !== 'publicVote') {

Expand Down
28 changes: 20 additions & 8 deletions src/js/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@
-->

<template>
<AppSidebar ref="sideBar" :title="t('polls', 'Details')" @close="$emit('closeSideBar')">
<AppSidebarTab :name="t('polls', 'Comments')" icon="icon-comment">
<Comments />
<AppSidebar ref="sideBar" :active="active" :title="t('polls', 'Details')"
@close="$emit('closeSideBar')">
<AppSidebarTab v-if="acl.allowEdit" :order="1" :name="t('polls', 'Configuration')"
icon="icon-settings">
<SideBarTabConfiguration />
</AppSidebarTab>

<AppSidebarTab v-if="acl.allowEdit" :name="t('polls', 'options')" icon="icon-toggle-filelist">
<AppSidebarTab v-if="acl.allowEdit" :order="2" :name="t('polls', 'Options')"
icon="icon-toggle-filelist">
<SideBarTabOptions />
</AppSidebarTab>

<AppSidebarTab v-if="acl.allowEdit" :name="t('polls', 'Configuration')" icon="icon-settings">
<SideBarTabConfiguration />
<AppSidebarTab v-if="acl.allowEdit" :order="3" :name="t('polls', 'Shares')"
icon="icon-share">
<SideBarTabShare />
</AppSidebarTab>

<AppSidebarTab v-if="acl.allowEdit" :name="t('polls', 'Shares')" icon="icon-share">
<SideBarTabShare />
<AppSidebarTab :order="4" :name="t('polls', 'Comments')" icon="icon-comment">
<Comments />
</AppSidebarTab>
</AppSidebar>
</template>
Expand All @@ -51,6 +55,7 @@ import { mapState } from 'vuex'

export default {
name: 'SideBar',

components: {
SideBarTabConfiguration,
Comments,
Expand All @@ -60,6 +65,13 @@ export default {
AppSidebarTab
},

props: {
active: {
type: String,
default: t('polls', 'Comments').toLowerCase()
}
},

computed: {
...mapState({
poll: state => state.poll,
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/VoteTable/VoteList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {

...mapGetters([
'sortedOptions',
'participants',
'participantsVoted',
'votesRank',
'expired'
]),
Expand Down Expand Up @@ -100,7 +100,7 @@ export default {
},

noVotes(pollOptionText) {
return this.participants.length - this.maybeVotes(pollOptionText) - this.yesVotes(pollOptionText)
return this.participantsVoted.length - this.maybeVotes(pollOptionText) - this.yesVotes(pollOptionText)
},

setVote(option, participant) {
Expand Down
4 changes: 4 additions & 0 deletions src/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default new Router({
props: true,
name: 'vote'
},
{
path: '/poll/:token',
redirect: '/s/:token'
},
{
path: '/s/:token',
components: {
Expand Down
6 changes: 5 additions & 1 deletion src/js/store/modules/votes.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const getters = {
}
},

participantsVoted: (state, getters) => {
return [...new Set(state.list.map(item => item.userId))]
},

participants: (state, getters, rootState) => {
const list = []
state.list.forEach(function(vote) {
Expand All @@ -71,7 +75,7 @@ const getters = {
}
})

if (!list.includes(rootState.acl.userId) && rootState.acl.userId !== null) {
if (!list.includes(rootState.acl.userId) && rootState.acl.userId && rootState.acl.allowVote) {
list.push(rootState.acl.userId)
}

Expand Down
21 changes: 17 additions & 4 deletions src/js/views/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
<VoteTable v-show="tableMode && options.list.length" />
<div v-if="!options.list.length" class="emptycontent">
<div class="icon-toggle-filelist" />
<p> {{ t('polls', 'There are no vote options, add some.') }}</p>
<button @click="openOptions">
{{ t('polls', 'There are no vote options, add some in the options section of the right side bar.') }}
</button>
</div>

<Subscription />
Expand All @@ -47,7 +49,7 @@
</div>
</div>

<SideBar v-if="sideBarOpen" @closeSideBar="toggleSideBar" />
<SideBar v-if="sideBarOpen" :active="activeTab" @closeSideBar="toggleSideBar" />
<LoadingOverlay v-if="isLoading" />
</AppContent>
</template>
Expand Down Expand Up @@ -90,7 +92,8 @@ export default {
isLoading: false,
initialTab: 'comments',
newName: '',
tableMode: true
tableMode: true,
activeTab: t('polls', 'Comments').toLowerCase()
}
},

Expand Down Expand Up @@ -118,14 +121,24 @@ export default {
},

methods: {
openOptions() {
this.sideBarOpen = true
this.activeTab = t('polls', 'Options').toLowerCase()
},

openConfiguration() {
this.sideBarOpen = true
this.activeTab = t('polls', 'Configuration').toLowerCase()
},

loadPoll() {
this.isLoading = true
this.$store.dispatch({ type: 'loadPollMain', pollId: this.$route.params.id })
.then(() => {
this.$store.dispatch({ type: 'loadPoll', pollId: this.$route.params.id })
.then(() => {
if (this.acl.allowEdit && moment.unix(this.poll.created).diff() > -10000) {
this.sideBarOpen = true
this.openConfiguration()
}
this.isLoading = false
})
Expand Down