Skip to content

Commit

Permalink
frontend/Collaborators.vue: enable/show edit functions only for manager
Browse files Browse the repository at this point in the history
Issue: ecamp#1415
  • Loading branch information
BacLuc committed Jun 6, 2021
1 parent 7b0eec8 commit 3a49056
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/camp/CollaboratorListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
v-if="collaborator.status === 'invited'"
class="ml-2">
<icon-button
v-if="!disabled"
color="normal"
icon="mdi-refresh"
:animate="resendingEmail"
Expand All @@ -36,10 +37,12 @@
item-text="translation"
:my="0"
dense
vee-rules="required" />
vee-rules="required"
:disabled="disabled" />
</v-list-item-action>
<v-list-item-action class="ml-2">
<button-delete
v-if="!disabled"
icon="mdi-cancel"
@click="api.del(collaborator)">
{{ $tc("components.camp.collaboratorListItem.deactivate") }}
Expand All @@ -58,7 +61,8 @@ export default {
name: 'CollaboratorListItem',
components: { ButtonDelete, ApiSelect, UserAvatar, IconButton },
props: {
collaborator: { type: Object, required: true }
collaborator: { type: Object, required: true },
disabled: { type: Boolean, default: false }
},
data: () => ({
resendingEmail: false
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/components/camp/InactiveCollaboratorListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action class="ml-5">
<icon-button color="normal"
icon="mdi-refresh"
@click="api.patch(collaborator, {status: 'invited'})">
<icon-button
v-if="!disabled"
color="normal"
icon="mdi-refresh"
@click="api.patch(collaborator, {status: 'invited'})">
{{ $tc('components.camp.inactiveCampCollaboratorListItem.inviteAgain') }}
</icon-button>
</v-list-item-action>
<v-list-item-action>
<dialog-entity-delete :entity="collaborator">
<dialog-entity-delete v-if="!disabled" :entity="collaborator">
<template #activator="{ on }">
<button-delete v-on="on" />
</template>
Expand Down Expand Up @@ -50,7 +52,8 @@ export default {
name: 'InactiveCollaboratorListItem',
components: { IconButton, ButtonDelete, DialogEntityDelete, UserAvatar },
props: {
collaborator: { type: Object, required: true }
collaborator: { type: Object, required: true },
disabled: { type: Boolean, default: false }
}
}
</script>
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/views/camp/Collaborators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ Displays collaborators of a single camp.
<v-skeleton-loader v-if="collaborators.length <= 0" type="list-item-avatar-two-line@3" class="px-0" />
<collaborator-list-item
v-for="collaborator in establishedCollaborators"
:key="collaborator._meta.self" :collaborator="collaborator" />
:key="collaborator._meta.self" :collaborator="collaborator"
:disabled="!isManager" />
</v-list>
</content-group>

<content-group v-if="invitedCollaborators.length > 0" :title="$tc('views.camp.collaborators.openInvitations')">
<v-list>
<collaborator-list-item
v-for="collaborator in invitedCollaborators"
:key="collaborator._meta.self" :collaborator="collaborator" />
:key="collaborator._meta.self" :collaborator="collaborator"
:disabled="!isManager" />
</v-list>
</content-group>

<content-group v-if="inactiveCollaborators.length > 0" :title="$tc('views.camp.collaborators.inactiveCollaborators')">
<v-list>
<inactive-collaborator-list-item
v-for="collaborator in inactiveCollaborators"
:key="collaborator._meta.self" :collaborator="collaborator" />
:key="collaborator._meta.self" :collaborator="collaborator"
:disabled="!isManager" />
</v-list>
</content-group>

<content-group :title="$tc('views.camp.collaborators.invite')">
<content-group v-if="isManager" :title="$tc('views.camp.collaborators.invite')">
<v-form @submit.prevent="invite">
<v-container>
<v-row
Expand Down Expand Up @@ -78,6 +81,7 @@ import ButtonAdd from '@/components/buttons/ButtonAdd.vue'
import ETextField from '@/components/form/base/ETextField.vue'
import ESelect from '@/components/form/base/ESelect.vue'
import InactiveCollaboratorListItem from '@/components/camp/InactiveCollaboratorListItem.vue'
import { campRoleMixin } from '@/mixins/campRoleMixin'
const DEFAULT_INVITE_ROLE = 'member'
Expand All @@ -92,6 +96,7 @@ export default {
ESelect,
InactiveCollaboratorListItem
},
mixins: [campRoleMixin],
props: {
camp: { type: Function, required: true }
},
Expand Down

0 comments on commit 3a49056

Please sign in to comment.