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 authored and miaulalala committed Nov 22, 2021
1 parent 7023a7a commit 105fe19
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 26 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"
@remove-attendee="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 @@ -111,6 +111,10 @@ export default {
type: Boolean,
required: true,
},
isViewedByOrganizer: {
type: Boolean,
required: true,
},
},
computed: {
avatarLink() {
Expand Down Expand Up @@ -143,10 +147,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 @@ -30,6 +30,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 @@ -210,6 +211,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 @@ -260,6 +274,9 @@ export default {
if (this.isLoading) {
return false
}
if (this.isViewedByAttendee) {
return false
}

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

<PropertyTitleTimePicker
:start-date="startDate"
:start-timezone="startTimezone"
: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"
:append-to-body="true"
Expand All @@ -122,43 +122,43 @@
</template>
<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"
@add-single-value="addCategory"
@remove-single-value="removeCategory" />

<PropertyColor
:calendar-color="selectedCalendarColor"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isViewedByAttendee"
:prop-model="rfcProps.color"
:value="color"
@update:value="updateColor" />
Expand Down Expand Up @@ -199,7 +199,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 @@ -222,6 +223,27 @@
<div class="app-sidebar-tab__content">
<ResourceList
v-if="!isLoading"
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly || isViewedByAttendee" />
</div>
<SaveButtons
v-if="showSaveButtons"
class="app-sidebar-tab__buttons"
:can-create-recurrence-exception="canCreateRecurrenceException"
:is-new="isNew"
:force-this-and-all-future="forceThisAndAllFuture"
@save-this-only="saveAndLeave(false)"
@save-this-and-all-future="saveAndLeave(true)" />
</AppSidebarTab>
<AppSidebarTab
v-if="!isLoading && !isError"
id="app-sidebar-tab-reminders"
class="app-sidebar-tab"
icon="icon-reminder"
:name="$t('calendar', 'Reminders')"
:order="3">
<div class="app-sidebar-tab__content">
<AlarmList
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly" />
</div>
Expand All @@ -234,6 +256,33 @@
@save-this-only="saveAndLeave(false)"
@save-this-and-all-future="saveAndLeave(true)" />
</AppSidebarTab>
<AppSidebarTab
v-if="!isLoading && !isError"
id="app-sidebar-tab-repeat"
class="app-sidebar-tab"
icon="icon-repeat"
:name="$t('calendar', 'Repeat')"
:order="4">
<div class="app-sidebar-tab__content">
<!-- TODO: If not editing the master item, force updating this and all future -->
<!-- TODO: You can't edit recurrence-rule of no-range recurrence-exception -->
<Repeat
:calendar-object-instance="calendarObjectInstance"
:recurrence-rule="calendarObjectInstance.recurrenceRule"
:is-read-only="isReadOnly || isViewedByAttendee"
:is-editing-master-item="isEditingMasterItem"
:is-recurrence-exception="isRecurrenceException"
@force-this-and-all-future="forceModifyingFuture" />
</div>
<SaveButtons
v-if="showSaveButtons"
class="app-sidebar-tab__buttons"
:can-create-recurrence-exception="canCreateRecurrenceException"
:is-new="isNew"
:force-this-and-all-future="forceThisAndAllFuture"
@save-this-only="saveAndLeave(false)"
@save-this-and-all-future="saveAndLeave(true)" />
</AppSidebarTab>
</AppSidebar>
</template>
<script>
Expand Down
12 changes: 6 additions & 6 deletions src/views/EditSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,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"
@select-calendar="changeCalendar" />

<PropertyTitleTimePicker
Expand All @@ -128,7 +128,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"
@update-start-date="updateStartDate"
Expand All @@ -138,23 +138,23 @@
@toggle-all-day="toggleAllDay" />

<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" />

<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"
@save-this-only="saveAndLeave(false)"
@save-this-and-all-future="saveAndLeave(true)"
@show-more="showMore" />
Expand Down

0 comments on commit 105fe19

Please sign in to comment.