Skip to content

Commit

Permalink
Fix events being editable by invitees
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed Aug 20, 2021
1 parent cc5b67e commit af27697
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
5 changes: 5 additions & 0 deletions src/components/Editor/Invitees/InviteesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
:key="invitee.email"
:attendee="invitee"
:is-read-only="isReadOnly"
:is-viewed-by-organizer="isViewedByOrganizer"
:organizer-display-name="organizerDisplayName"
@removeAttendee="removeAttendee" />
<NoAttendeesView
Expand Down Expand Up @@ -99,6 +100,10 @@ export default {
type: Boolean,
required: true,
},
isViewedByOrganizer: {
type: Boolean,
required: true,
},
calendarObjectInstance: {
type: Object,
required: true,
Expand Down
10 changes: 5 additions & 5 deletions src/components/Editor/Invitees/InviteesListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{{ commonName }}
</div>
<div class="invitees-list-item__actions">
<Actions v-if="isViewedByOrganizer">
<Actions v-if="!isReadOnly && isViewedByOrganizer">
<ActionCheckbox
:checked="attendee.rsvp"
@change="toggleRSVP">
Expand Down Expand Up @@ -106,6 +106,10 @@ export default {
type: Boolean,
required: true,
},
isViewedByOrganizer: {
type: Boolean,
required: true,
},
},
computed: {
avatarLink() {
Expand Down Expand Up @@ -138,10 +142,6 @@ export default {
isNonParticipant() {
return this.attendee.role === 'NON-PARTICIPANT'
},
isViewedByOrganizer() {
// TODO: check if also viewed by organizer
return !this.isReadOnly
},
},
methods: {
/**
Expand Down
12 changes: 8 additions & 4 deletions src/components/Editor/SaveButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ export default {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false,
},
},
computed: {
showSaveButton() {
return this.isNew && !this.canCreateRecurrenceException
return this.isNew && !this.canCreateRecurrenceException && !this.isReadOnly
},
shoUpdateButton() {
return !this.isNew && !this.canCreateRecurrenceException
return !this.isNew && !this.canCreateRecurrenceException && !this.isReadOnly
},
showUpdateOnlyThisButton() {
return this.canCreateRecurrenceException && !this.forceThisAndAllFuture
return this.canCreateRecurrenceException && !this.forceThisAndAllFuture && !this.isReadOnly
},
showUpdateThisAndFutureButton() {
return this.canCreateRecurrenceException
return this.canCreateRecurrenceException && !this.isReadOnly
},
},
methods: {
Expand Down
17 changes: 17 additions & 0 deletions src/mixins/EditorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
mapState,
} from 'vuex'
import { translate as t } from '@nextcloud/l10n'
import { removeMailtoPrefix } from '../utils/attendee'

/**
* This is a mixin for the editor. It contains common Vue stuff, that is
Expand Down Expand Up @@ -207,6 +208,19 @@ export default {

return calendar.readOnly
},
/**
* Returns whether or not an attendee is viewing the event
*
* @return {boolean}
*/
isViewedByAttendee() {
if (!this.calendarObjectInstance.organizer) {
return false
}

const principal = removeMailtoPrefix(this.$store.getters.getCurrentUserPrincipalEmail)
return removeMailtoPrefix(this.calendarObjectInstance.organizer.uri) !== principal
},
/**
* Returns all calendars selectable by the user
*
Expand Down Expand Up @@ -257,6 +271,9 @@ export default {
if (this.isLoading) {
return false
}
if (this.isViewedByAttendee) {
return false
}

return this.calendarObject.existsOnServer
},
Expand Down
25 changes: 13 additions & 12 deletions src/views/EditSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
v-if="showCalendarPicker"
:calendars="calendars"
:calendar="selectedCalendar"
:is-read-only="isReadOnly || !canModifyCalendar"
:is-read-only="isReadOnly || !canModifyCalendar || isViewedByAttendee"
@selectCalendar="changeCalendar" />

<PropertyTitleTimePicker
Expand All @@ -86,7 +86,7 @@
:end-date="endDate"
:end-timezone="endTimezone"
:is-all-day="isAllDay"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:can-modify-all-day="canModifyAllDay"
:user-timezone="currentUserTimezone"
@updateStartDate="updateStartDate"
Expand All @@ -105,43 +105,43 @@
:order="0">
<div class="app-sidebar-tab__content">
<PropertyText
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.location"
:value="location"
@update:value="updateLocation" />
<PropertyText
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.description"
:value="description"
@update:value="updateDescription" />

<PropertySelect
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.status"
:value="status"
@update:value="updateStatus" />
<PropertySelect
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.accessClass"
:value="accessClass"
@update:value="updateAccessClass" />
<PropertySelect
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.timeTransparency"
:value="timeTransparency"
@update:value="updateTimeTransparency" />

<PropertySelectMultiple
:colored-options="true"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.categories"
:value="categories"
@addSingleValue="addCategory"
@removeSingleValue="removeCategory" />

<PropertyColor
:calendar-color="selectedCalendarColor"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.color"
:value="color"
@update:value="updateColor" />
Expand All @@ -166,7 +166,8 @@
<InviteesList
v-if="!isLoading"
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly" />
:is-viewed-by-organizer="!isViewedByAttendee"
:is-read-only="isReadOnly || isViewedByAttendee" />
</div>
<SaveButtons
v-if="showSaveButtons"
Expand All @@ -188,7 +189,7 @@
<ResourceList
v-if="!isLoading"
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly" />
:is-read-only="isReadOnly || isViewedByAttendee" />
</div>
<SaveButtons
v-if="showSaveButtons"
Expand Down Expand Up @@ -233,7 +234,7 @@
<Repeat
:calendar-object-instance="calendarObjectInstance"
:recurrence-rule="calendarObjectInstance.recurrenceRule"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:is-editing-master-item="isEditingMasterItem"
:is-recurrence-exception="isRecurrenceException"
@forceThisAndAllFuture="forceModifyingFuture" />
Expand Down
12 changes: 6 additions & 6 deletions src/views/EditSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@

<PropertyTitle
:value="title"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
@update:value="updateTitle" />

<PropertyCalendarPicker
v-if="showCalendarPicker"
:calendars="calendars"
:calendar="selectedCalendar"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
@selectCalendar="changeCalendar" />

<PropertyTitleTimePicker
Expand All @@ -91,7 +91,7 @@
:end-date="endDate"
:end-timezone="endTimezone"
:is-all-day="isAllDay"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:can-modify-all-day="canModifyAllDay"
:user-timezone="currentUserTimezone"
@updateStartDate="updateStartDate"
Expand All @@ -102,24 +102,24 @@

<PropertyText
v-if="hasLocation"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.location"
:value="location"
@update:value="updateLocation" />
<PropertyText
v-if="hasDescription"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.description"
:value="description"
@update:value="updateDescription" />

<SaveButtons
v-if="!isReadOnly"
class="event-popover__buttons"
:can-create-recurrence-exception="canCreateRecurrenceException"
:is-new="isNew"
:force-this-and-all-future="forceThisAndAllFuture"
:show-more-button="true"
:is-read-only="isReadOnly || isViewedByAttendee"
@saveThisOnly="saveAndLeave(false)"
@saveThisAndAllFuture="saveAndLeave(true)"
@showMore="showMore" />
Expand Down

0 comments on commit af27697

Please sign in to comment.