Skip to content

Commit aef00a2

Browse files
fixup! fix: calendar import
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent c87ecbd commit aef00a2

7 files changed

Lines changed: 250 additions & 134 deletions

File tree

src/components/AppNavigation/Settings.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ export default {
277277
return isAfterVersion(34)
278278
},
279279
280-
files() {
281-
return this.importStore.importFiles
282-
},
283-
284280
hasBirthdayCalendar() {
285281
return !!this.calendarsStore.getBirthdayCalendar
286282
},

src/components/AppNavigation/Settings/ImportScreen.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@close="cancelImport">
1212
<template v-if="isSelecting">
1313
<transition-group class="import-modal__file-list" tag="ul">
14-
<ImportScreenRow v-for="(file, index) in files" :key="`import-file-${index}`" :file="file" />
14+
<ImportScreenRow v-for="entry in entries" :key="`import-file-${entry.file.id}`" :entry="entry" />
1515
</transition-group>
1616

1717
<div class="import-modal__actions">
@@ -22,7 +22,7 @@
2222
<template #icon>
2323
<Upload :size="20" />
2424
</template>
25-
{{ $n('calendar', 'Import calendar', 'Import calendars', files.length) }}
25+
{{ $n('calendar', 'Import calendar', 'Import calendars', entries.length) }}
2626
</NcButton>
2727
</div>
2828
</template>
@@ -75,7 +75,7 @@ export default {
7575
},
7676
7777
props: {
78-
files: {
78+
entries: {
7979
type: Array,
8080
required: true,
8181
},

src/components/AppNavigation/Settings/ImportScreenRow.vue

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
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"
@@ -14,16 +17,37 @@
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>
2549
import { getLanguage } from '@nextcloud/l10n'
26-
import { NcFormBox, NcFormBoxCopyButton, NcFormGroup } from '@nextcloud/vue'
50+
import { NcFormBox, NcFormBoxCopyButton, NcFormBoxSwitch, NcFormGroup, NcSelect } from '@nextcloud/vue'
2751
import { mapStores } from 'pinia'
2852
import CalendarPicker from '../../Shared/CalendarPicker.vue'
2953
import 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>

src/components/AppNavigation/Settings/SettingsImportSection.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<ImportScreen
3333
v-if="showImportModal"
34-
:files="files"
34+
:entries="entries"
3535
:stage="stage"
3636
:totals="totals"
3737
:activeSession="activeSession"
@@ -73,7 +73,7 @@ export default {
7373
computed: {
7474
...mapStores(useImportStore, useCalendarObjectsStore),
7575
...mapState(useImportStore, {
76-
files: 'importFiles',
76+
entries: 'files',
7777
}),
7878
7979
...mapState(useImportStore, {

0 commit comments

Comments
 (0)