Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/components/AppointmentConfigModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<label>{{ t('calendar', 'Calendar') }}</label>
<CalendarPicker v-if="calendar !== undefined"
:value="calendar"
:calendars="ownSortedCalendars"
:calendars="availableCalendars"
:show-calendar-on-select="false"
@select-calendar="changeCalendar" />
</div>
Expand All @@ -55,7 +55,7 @@

<div class="appointment-config-modal__form__row appointment-config-modal__form__row--local">
<label>{{ t('calendar', 'Additional calendars to check for conflicts') }}</label>
<CalendarPicker :value="conflictCalendars"
<CalendarPicker :value="selectedConflictCalendars"
:calendars="selectableConflictCalendars"
:multiple="true"
:show-calendar-on-select="false"
Expand Down Expand Up @@ -195,7 +195,7 @@
...mapState(useSettingsStore, {
isTalkEnabled: 'talkEnabled',
}),
...mapState(useCalendarsStore, ['ownSortedCalendars']),
...mapState(useCalendarsStore, ['ownSortedCalendars', 'sortedCalendars']),
...mapStores(useAppointmentConfigsStore, useCalendarsStore, useSettingsStore),
formTitle() {
if (this.showConfirmation) {
Expand All @@ -216,26 +216,34 @@
},
calendar() {
if (!this.editing.targetCalendarUri) {
return this.ownSortedCalendars[0]
return this.availableCalendars[0]

Check warning on line 219 in src/components/AppointmentConfigModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppointmentConfigModal.vue#L219

Added line #L219 was not covered by tests
}

const uri = this.editing.targetCalendarUri
const calendar = this.ownSortedCalendars.find(cal => this.calendarUrlToUri(cal.url) === uri)
return calendar || this.ownSortedCalendars[0]
const calendar = this.availableCalendars.find(cal => this.calendarUrlToUri(cal.url) === uri)
return calendar || this.availableCalendars[0]
},
// TODO: Can be removed after NC version 30 support is dropped
availableCalendars() {
const nextcloudMajorVersion = parseInt(window.OC.config.version.split('.')[0])
if (nextcloudMajorVersion >= 31) {
return this.sortedCalendars
}
return this.ownSortedCalendars
},
selectableConflictCalendars() {
// The target calendar is always a conflict calendar, remove it from additional conflict calendars
return this.ownSortedCalendars.filter(calendar => calendar.url !== this.calendar.url)
return this.availableCalendars.filter(calendar => calendar.url !== this.calendar.url)

Check warning on line 236 in src/components/AppointmentConfigModal.vue

View check run for this annotation

Codecov / codecov/patch

src/components/AppointmentConfigModal.vue#L236

Added line #L236 was not covered by tests
},
conflictCalendars() {
selectedConflictCalendars() {
const freebusyUris = this.editing.calendarFreeBusyUris ?? []
return freebusyUris.map(uri => {
return this.ownSortedCalendars.find(cal => this.calendarUrlToUri(cal.url) === uri)
})
return this.availableCalendars.find(cal => this.calendarUrlToUri(cal.url) === uri)
}).filter(calendar => calendar !== undefined)
},
defaultConfig() {
return AppointmentConfig.createDefault(
this.calendarUrlToUri(this.ownSortedCalendars[0].url),
this.calendarUrlToUri(this.availableCalendars[0].url),
this.calendarsStore.scheduleInbox,
this.settingsStore.getResolvedTimezone,
)
Expand Down
Loading