diff options
author | dartcafe <github@dartcafe.de> | 2020-01-29 01:09:26 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-01-29 01:09:26 +0300 |
commit | 9cb5ec7dcff3ade3230785a10e8f08f116295976 (patch) | |
tree | 6ca10f45ffc19a7184727c89d828bdc0681dd61d | |
parent | e966bb58c5b14bac5c73ec61050238c0eee97430 (diff) |
Allow/Deny admin access
-rw-r--r-- | lib/Db/Poll.php | 2 | ||||
-rw-r--r-- | src/js/components/Navigation/PollNavigationItems.vue | 8 | ||||
-rw-r--r-- | src/js/components/PollList/PollListItem.vue | 8 | ||||
-rw-r--r-- | src/js/components/SideBar/SideBarTabConfiguration.vue | 18 | ||||
-rw-r--r-- | src/js/components/SideBar/SideBarTabOptions.vue | 4 | ||||
-rw-r--r-- | src/js/components/SideBar/SideBarTabShare.vue | 11 |
6 files changed, 38 insertions, 13 deletions
diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php index 92a6e66f..ef8ffc28 100644 --- a/lib/Db/Poll.php +++ b/lib/Db/Poll.php @@ -131,7 +131,7 @@ class Poll extends Entity implements JsonSerializable { 'settings' => $this->settings, 'voteLimit' => intval($this->voteLimit), 'showResults' => $this->showResults, - 'adminAccess' => $this->adminAccess + 'adminAccess' => intVal($this->adminAccess) ]; } } diff --git a/src/js/components/Navigation/PollNavigationItems.vue b/src/js/components/Navigation/PollNavigationItems.vue index dd4ca532..8fe69b45 100644 --- a/src/js/components/Navigation/PollNavigationItems.vue +++ b/src/js/components/Navigation/PollNavigationItems.vue @@ -27,12 +27,12 @@ {{ t('polls', 'Clone poll') }} </ActionButton> - <ActionButton v-if="poll.owner === OC.getCurrentUser().uid && !poll.deleted" icon="icon-delete" @click="$emit('switchDeleted')"> - {{ t('polls', 'Delete poll') }} + <ActionButton v-if="poll.allowEdit && !poll.deleted" icon="icon-delete" @click="$emit('switchDeleted')"> + {{ (poll.isAdmin) ? t('polls', 'Delete poll as admin') : t('polls', 'Delete poll') }} </ActionButton> - <ActionButton v-if="poll.owner === OC.getCurrentUser().uid && poll.deleted" icon="icon-history" @click="$emit('switchDeleted')"> - {{ t('polls', 'Restore poll') }} + <ActionButton v-if="poll.allowEdit && poll.deleted" icon="icon-history" @click="$emit('switchDeleted')"> + {{ (poll.isAdmin) ? t('polls', 'Restore poll as admin') : t('polls', 'Restore poll') }} </ActionButton> </template> </AppNavigationItem> diff --git a/src/js/components/PollList/PollListItem.vue b/src/js/components/PollList/PollListItem.vue index 9f8a2cdd..8b10a77f 100644 --- a/src/js/components/PollList/PollListItem.vue +++ b/src/js/components/PollList/PollListItem.vue @@ -67,12 +67,12 @@ {{ t('polls', 'Clone poll') }} </ActionButton> - <ActionButton v-if="poll.owner === OC.getCurrentUser().uid && !poll.deleted" icon="icon-delete" @click="switchDeleted()"> - {{ t('polls', 'Delete poll') }} + <ActionButton v-if="poll.allowEdit && !poll.deleted" icon="icon-delete" @click="switchDeleted()"> + {{ (poll.isAdmin) ? t('polls', 'Delete poll as admin') : t('polls', 'Delete poll') }} </ActionButton> - <ActionButton v-if="poll.owner === OC.getCurrentUser().uid && poll.deleted" icon="icon-history" @click="switchDeleted()"> - {{ t('polls', 'Restore poll') }} + <ActionButton v-if="poll.allowEdit && poll.deleted" icon="icon-history" @click="switchDeleted()"> + {{ (poll.isAdmin) ? t('polls', 'Restore poll as admin') : t('polls', 'Restore poll') }} </ActionButton> </Actions> diff --git a/src/js/components/SideBar/SideBarTabConfiguration.vue b/src/js/components/SideBar/SideBarTabConfiguration.vue index 7a8fd207..8cd7fd5f 100644 --- a/src/js/components/SideBar/SideBarTabConfiguration.vue +++ b/src/js/components/SideBar/SideBarTabConfiguration.vue @@ -22,9 +22,8 @@ <template> <div> - <div class="config-box"> - <label v-if="writingPoll" class="icon-loading-small title"> {{ t('polls', 'Saving') }} </label> - <label v-else class="icon-checkmark title"> {{ t('polls', 'Saved') }} </label> + <div v-if="acl.isAdmin" class="config-box"> + <label class="icon-checkmark title"> {{ t('polls', 'As an admin you may edit this poll') }} </label> </div> <div v-if="acl.allowEdit" class="config-box"> @@ -40,6 +39,10 @@ <div class="config-box"> <label class="title icon-category-customization"> {{ t('polls', 'Poll configurations') }} </label> + <input v-if="!acl.isAdmin" id="adminAccess" v-model="pollAdminAccess" + type="checkbox" class="checkbox"> + <label v-if="!acl.isAdmin" for="adminAccess" class="title"> {{ t('polls', 'Allow admins to edit this poll') }} </label> + <input id="allowMaybe" v-model="pollAllowMaybe" type="checkbox" class="checkbox"> <label for="allowMaybe" class="title"> {{ t('polls', 'Allow "maybe" vote') }} </label> @@ -185,6 +188,15 @@ export default { } }, + pollAdminAccess: { + get() { + return (this.poll.adminAccess > 0) + }, + set(value) { + this.writeValue({ adminAccess: value }) + } + }, + pollAllowMaybe: { get() { return this.poll.allowMaybe diff --git a/src/js/components/SideBar/SideBarTabOptions.vue b/src/js/components/SideBar/SideBarTabOptions.vue index ebc420a8..6b5975f0 100644 --- a/src/js/components/SideBar/SideBarTabOptions.vue +++ b/src/js/components/SideBar/SideBarTabOptions.vue @@ -22,6 +22,10 @@ <template> <div> + <div v-if="acl.isAdmin" class="config-box"> + <label class="icon-checkmark title"> {{ t('polls', 'As an admin you may edit this poll') }} </label> + </div> + <SideBarTabDateOptions v-if="acl.allowEdit && poll.type === 'datePoll'" /> <SideBarTabTextOptions v-if="acl.allowEdit && poll.type === 'textPoll'" /> </div> diff --git a/src/js/components/SideBar/SideBarTabShare.vue b/src/js/components/SideBar/SideBarTabShare.vue index a75fd162..9aef6c92 100644 --- a/src/js/components/SideBar/SideBarTabShare.vue +++ b/src/js/components/SideBar/SideBarTabShare.vue @@ -22,7 +22,12 @@ <template> <div> + <div v-if="acl.isAdmin" class="config-box"> + <label class="icon-checkmark title"> {{ t('polls', 'As an admin you may edit this poll') }} </label> + </div> + <h3>{{ t('polls','Invitations') }}</h3> + <span>{{ t('polls','Invited users will get informed immediately via eMail!') }} </span> <TransitionGroup :css="false" tag="ul" class="shared-list"> <li v-for="(share) in invitationShares" :key="share.id"> @@ -88,7 +93,7 @@ <script> import { Multiselect } from '@nextcloud/vue' -import { mapGetters } from 'vuex' +import { mapState, mapGetters } from 'vuex' export default { name: 'SideBarTabShare', @@ -114,6 +119,10 @@ export default { }, computed: { + ...mapState({ + acl: state => state.acl + }), + ...mapGetters([ 'invitationShares', 'publicShares' |