Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Heinrich committed Aug 18, 2023
1 parent 79a24df commit 0d8c975
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 27 deletions.
21 changes: 17 additions & 4 deletions src/components/Editor/AvatarParticipationStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@

<template>
<div class="avatar-participation-status">
<Avatar :disable-tooltip="true"
<Avatar v-if="isCircle === true">
<template #icon>
<GoogleCirclesCommunitiesIcon :size="32" />
</template>
</Avatar>
<Avatar v-if="isCircle !== true"
:disable-tooltip="true"
:user="avatarLink"
:is-no-user="isResource" />

<template v-if="participationStatus === 'ACCEPTED' && isViewedByOrganizer">
<IconCheck class="avatar-participation-status__indicator"
fill-color="#32CD32"
Expand Down Expand Up @@ -124,7 +131,8 @@
</template>

<script>
import { NcAvatar as Avatar } from '@nextcloud/vue'
import Avatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import GoogleCirclesCommunitiesIcon from 'vue-material-design-icons/GoogleCirclesCommunities.vue'
import IconCheck from 'vue-material-design-icons/CheckCircle.vue'
import IconNoResponse from 'vue-material-design-icons/HelpCircle.vue'
import IconClose from 'vue-material-design-icons/CloseCircle.vue'
Expand All @@ -133,8 +141,9 @@ import IconDelegated from 'vue-material-design-icons/ArrowRightDropCircle.vue'
export default {
name: 'AvatarParticipationStatus',
components: {
Avatar,
IconCheck,
Avatar,
GoogleCirclesCommunitiesIcon,
IconCheck,
IconNoResponse,
IconClose,
IconDelegated,
Expand All @@ -161,6 +170,10 @@ export default {
type: Boolean,
required: true,
},
isCircle: {
type: Boolean,
required: false,
},
isSuggestion: {
type: Boolean,
default: false,
Expand Down
19 changes: 18 additions & 1 deletion src/components/Editor/Invitees/InviteesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:attendee="invitee"
:is-read-only="isReadOnly"
:organizer-display-name="organizerDisplayName"
:members="invitee.members"
@remove-attendee="removeAttendee" />
<NoAttendeesView v-if="isReadOnly && isListEmpty"
:message="noInviteesMessage" />
Expand Down Expand Up @@ -120,13 +121,29 @@ export default {
return !['RESOURCE', 'ROOM'].includes(attendee.attendeeProperty.userType)
})
},
groups() {
return this.calendarObjectInstance.attendees.filter(attendee => {
return attendee.attendeeProperty.userType === 'GROUP'
})
},
inviteesWithoutOrganizer() {
if (!this.calendarObjectInstance.organizer) {
return this.invitees
}
return this.invitees
.filter(attendee => attendee.uri !== this.calendarObjectInstance.organizer.uri)
.filter(attendee => {
// Filter attendees which are part of an invited group
if (attendee.member) {
var isMemberOfGroup = this.groups.some(function(group) {

Check failure on line 138 in src/components/Editor/Invitees/InviteesList.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected var, use let or const instead
return attendee.member.includes(group.uri) &&

Check failure on line 139 in src/components/Editor/Invitees/InviteesList.vue

View workflow job for this annotation

GitHub Actions / eslint

'&&' should be placed at the beginning of the line
attendee.attendeeProperty.userType === 'INDIVIDUAL'
})
}
return attendee.uri !== this.calendarObjectInstance.organizer.uri &&

Check failure on line 144 in src/components/Editor/Invitees/InviteesList.vue

View workflow job for this annotation

GitHub Actions / eslint

'&&' should be placed at the beginning of the line
!isMemberOfGroup
})
},
hasOrganizer() {
return this.calendarObjectInstance.organizer !== null
Expand Down
86 changes: 64 additions & 22 deletions src/components/Editor/Invitees/InviteesListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,51 @@

<template>
<div class="invitees-list-item">
<AvatarParticipationStatus :attendee-is-organizer="false"
:is-viewed-by-organizer="isViewedByOrganizer"
:is-resource="false"
:avatar-link="avatarLink"
:participation-status="attendee.participationStatus"
:organizer-display-name="organizerDisplayName"
:common-name="commonName" />
<AvatarParticipationStatus :attendee-is-organizer="false" :is-viewed-by-organizer="isViewedByOrganizer"

Check failure on line 26 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

':is-viewed-by-organizer' should be on a new line
:is-resource="false" :avatar-link="avatarLink" :participation-status="attendee.participationStatus"

Check failure on line 27 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

':avatar-link' should be on a new line

Check failure on line 27 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

':participation-status' should be on a new line
:organizer-display-name="organizerDisplayName" :common-name="commonName" :is-circle="isCircle" />

Check failure on line 28 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

':common-name' should be on a new line

Check failure on line 28 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

':is-circle' should be on a new line
<div class="invitees-list-item__displayname">
{{ commonName }}
</div>
<div class="invitees-list-item__actions">
<NcButton class="icon-collapse" v-if="isCircle"

Check failure on line 33 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

'v-if' should be on a new line

Check warning on line 33 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Attribute "v-if" should go before "class"
:class="{ 'icon-collapse--open': memberListExpaneded }"
type="tertiary"
:aria-label="labelButton" @click="toggleMemberList">

Check failure on line 36 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

'@click' should be on a new line
<template this#icon>

Check warning on line 37 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

`<template>` require directive
<ChevronUp v-if="memberListExpaneded" :size="20" />
<ChevronDown v-else :size="20" />
</template>
</NcButton>
<Actions v-if="isViewedByOrganizer">
<ActionCheckbox :checked="attendee.rsvp"
@change="toggleRSVP">
<ActionCheckbox :checked="attendee.rsvp" @change="toggleRSVP">
{{ $t('calendar', 'Send email') }}
</ActionCheckbox>

<ActionRadio :name="radioName"
:checked="isChair"
@change="changeRole('CHAIR')">
<ActionRadio :name="radioName" :checked="isChair" @change="changeRole('CHAIR')">
{{ $t('calendar', 'Chairperson') }}
</ActionRadio>
<ActionRadio :name="radioName"
:checked="isRequiredParticipant"
@change="changeRole('REQ-PARTICIPANT')">
<ActionRadio :name="radioName" :checked="isRequiredParticipant" @change="changeRole('REQ-PARTICIPANT')">
{{ $t('calendar', 'Required participant') }}
</ActionRadio>
<ActionRadio :name="radioName"
:checked="isOptionalParticipant"
@change="changeRole('OPT-PARTICIPANT')">
<ActionRadio :name="radioName" :checked="isOptionalParticipant" @change="changeRole('OPT-PARTICIPANT')">
{{ $t('calendar', 'Optional participant') }}
</ActionRadio>
<ActionRadio :name="radioName"
:checked="isNonParticipant"
@change="changeRole('NON-PARTICIPANT')">
<ActionRadio :name="radioName" :checked="isNonParticipant" @change="changeRole('NON-PARTICIPANT')">
{{ $t('calendar', 'Non-participant') }}
</ActionRadio>

<ActionButton @click="removeAttendee">
<template #icon>
<Delete :size="20" decorative />
</template>
{{ $t('calendar', 'Remove attendee') }}
{{ removeAttendeeText }}
</ActionButton>
</Actions>
</div>
<div class="member-list">
hallo
</div>
</div>
</template>

Expand All @@ -81,6 +80,9 @@ import {
NcActionCheckbox as ActionCheckbox,
} from '@nextcloud/vue'
import { removeMailtoPrefix } from '../../../utils/attendee.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
Expand All @@ -93,6 +95,9 @@ export default {
ActionRadio,
Actions,
Delete,
NcButton,
ChevronDown,
ChevronUp,
},
props: {
attendee: {
Expand All @@ -108,6 +113,11 @@ export default {
required: true,
},
},
data() {
return {
memberListExpaneded: false

Check warning on line 118 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing trailing comma
};
},
computed: {
/**
* @return {string}
Expand All @@ -116,6 +126,16 @@ export default {
// return this.$store.getters.getAvatarForContact(this.uri) || this.commonName
return this.commonName
},
/**
* @return {string}
*/
removeAttendeeText() {
if (this.isCircle) {
return this.$t('calendar', 'Remove circle')
} else {
return this.$t('calendar', 'Remove attendee')
}
},
/**
* Common name of the organizer or the uri without the 'mailto:' prefix.
*
Expand Down Expand Up @@ -151,6 +171,12 @@ export default {
// TODO: check if also viewed by organizer
return !this.isReadOnly
},
isCircle() {
return this.attendee.attendeeProperty.userType === 'GROUP'
},
labelButton() {
return this.memberListExpaneded ? t('Collapse menu') : t('Open menu')
},
},
methods: {
/**
Expand Down Expand Up @@ -178,11 +204,22 @@ export default {
removeAttendee() {
this.$emit('remove-attendee', this.attendee)
},
/**

Check warning on line 207 in src/components/Editor/Invitees/InviteesListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "e" declaration
* Toggle member list if attendee is a group
*/
toggleMemberList(e) {
this.$emit('click', e)
this.memberListExpaneded = !this.memberListExpaneded
},
},
}
</script>

<style lang="scss" scoped>
.invitees-list-item__actions {
display: flex;
}
.invitees-list-item__displayname {
margin-bottom: 17px;
text-overflow: ellipsis;
Expand All @@ -193,4 +230,9 @@ export default {
.avatar-participation-status {
margin-top: 5px;
}
.member-list {
flex-basis: 100%;
width: 100%;
}
</style>
4 changes: 4 additions & 0 deletions src/models/attendee.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const getDefaultAttendeeObject = (props = {}) => Object.assign({}, {
rsvp: false,
// The uri of the attendee
uri: null,
// Member address of the attendee
member: null,
}, props)

/**
Expand All @@ -61,6 +63,8 @@ const mapAttendeePropertyToAttendeeObject = (attendeeProperty) => {
role: attendeeProperty.role,
rsvp: attendeeProperty.rsvp,
uri: attendeeProperty.email,
// TODO Expose member attribute in calendar-js
member: attendeeProperty._parameters.get('MEMBER')?._value ?? null,
})
}

Expand Down

0 comments on commit 0d8c975

Please sign in to comment.