51
51
:aria-label-combobox="t('mail', 'Select')"
52
52
label="displayname"
53
53
:options="calendarsForPicker">
54
- <template #option="{ option} ">
54
+ <template #option="option">
55
55
<CalendarPickerOption v-bind="option" />
56
56
</template>
57
- <template #singleLabel="{ option} ">
58
- <CalendarPickerOption :display-icon="true" v-bind="option" />
57
+ <template #selected-option=" option">
58
+ <CalendarPickerOption v-bind="option" />
59
59
</template>
60
60
</NcSelect>
61
61
</div>
@@ -196,6 +196,7 @@ export default {
196
196
...mapState(useMainStore, {
197
197
currentUserPrincipalEmail: 'getCurrentUserPrincipalEmail',
198
198
clonedWriteableCalendars: 'getClonedWriteableCalendars',
199
+ currentUserPrincipal: 'getCurrentUserPrincipal',
199
200
}),
200
201
201
202
/**
@@ -367,14 +368,23 @@ export default {
367
368
},
368
369
writable: calendar.currentUserPrivilegeSet.indexOf('{DAV:}write') !== -1,
369
370
url: calendar.url,
370
- dav: calendar,
371
371
}
372
372
}
373
373
374
374
return this.clonedWriteableCalendars
375
375
.map(getCalendarData)
376
376
.filter(props => props.components.vevent && props.writable === true)
377
377
},
378
+
379
+ /**
380
+ * Get the DAV object of the picked target calendar.
381
+ * It can't be included in the option as it contains cyclic references.
382
+ *
383
+ * @return {object | undefined}
384
+ */
385
+ targetCalendarDavObject() {
386
+ return this.clonedWriteableCalendars.find((cal) => cal.url === this.targetCalendar.url)
387
+ }
378
388
},
379
389
watch: {
380
390
attachedVEvent: {
@@ -386,7 +396,16 @@ export default {
386
396
calendarsForPicker: {
387
397
immediate: true,
388
398
handler(calendarsForPicker) {
389
- if (calendarsForPicker.length > 0 && !this.targetCalendar) {
399
+ if (this.targetCalendar) {
400
+ return
401
+ }
402
+
403
+ const defaultCalendar = calendarsForPicker.find(
404
+ (cal) => cal.url === this.currentUserPrincipal.scheduleDefaultCalendarUrl
405
+ )
406
+ if (defaultCalendar) {
407
+ this.targetCalendar = defaultCalendar
408
+ } else if (calendarsForPicker.length > 0) {
390
409
this.targetCalendar = calendarsForPicker[0]
391
410
}
392
411
},
@@ -415,7 +434,7 @@ export default {
415
434
return
416
435
}
417
436
418
- const calendar = this.targetCalendar?.dav
437
+ const calendar = this.targetCalendarDavObject
419
438
if (!calendar) {
420
439
return
421
440
}
0 commit comments