66<template >
77 <li class =" import-modal-file-item" >
88 <NcFormGroup :label =" $t (' calendar' , ' Calendar to import into' )" :description =" disabledHint " >
9+ <NcFormBox v-slot =" { itemClass } " >
10+ <NcFormBoxCopyButton :class =" itemClass " :label =" $t (' calendar' , ' File' )" :value =" file .name " />
11+ </NcFormBox >
912 <NcFormBox v-slot =" { itemClass } " >
1013 <CalendarPicker
1114 :class =" itemClass "
1417 :isCalendarSelectable =" isCalendarSelectable "
1518 @selectCalendar =" selectCalendar " />
1619 </NcFormBox >
20+ </NcFormGroup >
21+ <NcFormGroup :label =" $t (' calendar' , ' Import options' )" >
1722 <NcFormBox v-slot =" { itemClass } " >
18- <NcFormBoxCopyButton :class =" itemClass " :label =" $t (' calendar' , ' File' )" :value =" file .name " />
23+ <div class =" import-modal-file-item__format" :class =" itemClass" >
24+ <label :for =" formatInputId" class =" import-modal-file-item__format-label" >
25+ {{ $t('calendar', 'File format') }}
26+ </label >
27+ <NcSelect
28+ v-model =" selectedFormat "
29+ :inputId =" formatInputId "
30+ :options =" formatOptions "
31+ :allowEmpty =" false "
32+ :clearable =" false "
33+ label="label" />
34+ </div >
35+ </NcFormBox >
36+ <NcFormBox v-slot =" { itemClass } " >
37+ <NcFormBoxSwitch
38+ :class =" itemClass "
39+ :modelValue =" supersede "
40+ :label =" $t (' calendar' , ' Overwrite existing events' )"
41+ :description =" $t (' calendar' , ' Replace events in the calendar that match the imported ones instead of skipping them.' )"
42+ @update :modelValue =" setSupersede " />
1943 </NcFormBox >
2044 </NcFormGroup >
2145 </li >
2246</template >
2347
2448<script >
2549import { getLanguage } from ' @nextcloud/l10n'
26- import { NcFormBox , NcFormBoxCopyButton , NcFormGroup } from ' @nextcloud/vue'
50+ import { NcFormBox , NcFormBoxCopyButton , NcFormBoxSwitch , NcFormGroup , NcSelect } from ' @nextcloud/vue'
2751import { mapStores } from ' pinia'
2852import CalendarPicker from ' ../../Shared/CalendarPicker.vue'
2953import useCalendarsStore from ' ../../../store/calendars.js'
@@ -37,18 +61,63 @@ export default {
3761 CalendarPicker,
3862 NcFormBox,
3963 NcFormBoxCopyButton,
64+ NcFormBoxSwitch,
4065 NcFormGroup,
66+ NcSelect,
4167 },
4268
4369 props: {
44- file : {
70+ entry : {
4571 type: Object ,
4672 required: true ,
4773 },
4874 },
4975
5076 computed: {
5177 ... mapStores (usePrincipalsStore, useImportStore, useCalendarsStore),
78+
79+ file () {
80+ return this .entry .file
81+ },
82+
83+ formatInputId () {
84+ return ` import-format-${ this .file .id } `
85+ },
86+
87+ formatOptions () {
88+ return [{
89+ id: ' ical' ,
90+ label: this .$t (' calendar' , ' iCalendar (.ics)' ),
91+ }, {
92+ id: ' jcal' ,
93+ label: this .$t (' calendar' , ' jCal (.json)' ),
94+ }, {
95+ id: ' xcal' ,
96+ label: this .$t (' calendar' , ' xCal (.xml)' ),
97+ }]
98+ },
99+
100+ selectedFormat: {
101+ get () {
102+ const format = this .entry .options .format
103+ return this .formatOptions .find ((option ) => option .id === format) ?? this .formatOptions [0 ]
104+ },
105+
106+ set (option ) {
107+ if (! option) {
108+ return
109+ }
110+ this .importStore .setOptionsForFile ({
111+ fileId: this .file .id ,
112+ options: { format: option .id },
113+ })
114+ },
115+ },
116+
117+ supersede () {
118+ return this .entry .options .supersede
119+ },
120+
52121 newCalendar () {
53122 return {
54123 id: ' new' ,
@@ -60,7 +129,7 @@ export default {
60129 },
61130
62131 calendar () {
63- const calendarId = this .importStore . importCalendarRelation [ this . file . id ]
132+ const calendarId = this .entry . calendarId
64133 if (calendarId === this .newCalendar .id ) {
65134 return this .newCalendar
66135 }
@@ -130,11 +199,31 @@ export default {
130199 },
131200
132201 selectCalendar (newCalendar ) {
133- this .importStore .setCalendarForFileId ({
202+ this .importStore .setCalendarForFile ({
134203 fileId: this .file .id ,
135204 calendarId: newCalendar .id ,
136205 })
137206 },
207+
208+ setSupersede (supersede ) {
209+ this .importStore .setOptionsForFile ({
210+ fileId: this .file .id ,
211+ options: { supersede },
212+ })
213+ },
138214 },
139215}
140216< / script>
217+
218+ < style lang= " scss" scoped>
219+ .import - modal- file- item__format {
220+ display: flex;
221+ flex- direction: column;
222+ gap: 4px ;
223+ padding: 8px 12px ;
224+
225+ & - label {
226+ font- weight: bold;
227+ }
228+ }
229+ < / style>
0 commit comments