22
22
-->
23
23
24
24
<template>
25
- <AppNavigationItem v-click-outside="closeShareMenu"
26
- :loading="calendar.loading"
25
+ <AppNavigationItem :loading="calendar.loading"
27
26
:aria-description="descriptionAppNavigationItem"
28
27
:title="calendar.displayName || $t('calendar', 'Untitled calendar')"
29
- :class="{deleted: !!deleteTimeout, disabled: !calendar.enabled, 'open-sharing': shareMenuOpen }"
28
+ :class="{deleted: !!deleteTimeout, disabled: !calendar.enabled}"
30
29
@click.prevent.stop="toggleEnabled">
31
30
<template #icon>
32
31
<CheckboxBlankCircle v-if="calendar.enabled"
37
36
:fill-color="calendar.color" />
38
37
</template>
39
38
39
+ <template #counter>
40
+ <NcAvatar v-if="isSharedWithMe && loadedOwnerPrincipal" :user="ownerUserId" :display-name="ownerDisplayname" />
41
+ <div v-if="isSharedWithMe && !loadedOwnerPrincipal" class="icon icon-loading" />
42
+ </template>
43
+
40
44
<template #actions>
41
45
<template v-if="!deleteTimeout">
42
46
<ActionButton @click.prevent.stop="showEditModal">
43
47
<template #icon>
44
48
<Pencil :size="20" decorative />
45
49
</template>
46
- {{ $t('calendar', 'Edit calendar') }}
47
- </ActionButton>
48
- <ActionButton v-if="showRenameLabel"
49
- @click.prevent.stop="openRenameInput">
50
- <template #icon>
51
- <Pencil :size="20" decorative />
52
- </template>
53
- {{ $t('calendar', 'Edit name') }}
54
- </ActionButton>
55
- <ActionInput v-if="showRenameInput"
56
- :value="calendar.displayName"
57
- @submit.prevent.stop="saveRenameInput">
58
- <template #icon>
59
- <Pencil :size="20" decorative />
60
- </template>
61
- </ActionInput>
62
- <ActionText v-if="showRenameSaving"
63
- icon="icon-loading-small">
64
- <!-- eslint-disable-next-line no-irregular-whitespace -->
65
- {{ $t('calendar', 'Saving name …') }}
66
- </ActionText>
67
- <ActionButton v-if="showColorLabel"
68
- @click.prevent.stop="openColorInput">
69
- <template #icon>
70
- <Pencil :size="20" decorative />
71
- </template>
72
- {{ $t('calendar', 'Edit color') }}
50
+ {{ $t('calendar', 'Edit and share calendar') }}
73
51
</ActionButton>
74
- <ActionInput v-if="showColorInput"
75
- :value="calendar.color"
76
- type="color"
77
- @submit.prevent.stop="saveColorInput">
78
- <template #icon>
79
- <Pencil :size="20" decorative />
80
- </template>
81
- </ActionInput>
82
- <ActionText v-if="showColorSaving"
83
- icon="icon-loading-small">
84
- <!-- eslint-disable-next-line no-irregular-whitespace -->
85
- {{ $t('calendar', 'Saving color …') }}
86
- </ActionText>
87
52
<ActionButton @click.stop.prevent="copyLink">
88
53
<template #icon>
89
54
<LinkVariant :size="20" decorative />
113
78
</ActionButton>
114
79
</template>
115
80
116
- <template v-if="!! deleteTimeout">
81
+ <template v-if="deleteTimeout">
117
82
<ActionButton v-if="calendar.isSharedWithMe"
118
83
@click.prevent.stop="cancelDeleteCalendar">
119
84
<template #icon>
134
99
</template>
135
100
136
101
<script>
102
+ import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
137
103
import ActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
138
- import ActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
139
104
import ActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
140
- import ActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
141
105
import AppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js'
142
- import ClickOutside from 'vue-click-outside'
143
106
import {
144
- showInfo,
145
107
showSuccess,
146
108
showError,
147
109
} from '@nextcloud/dialogs'
@@ -161,10 +123,9 @@ import Undo from 'vue-material-design-icons/Undo.vue'
161
123
export default {
162
124
name: 'CalendarListItem',
163
125
components: {
126
+ NcAvatar,
164
127
ActionButton,
165
- ActionInput,
166
128
ActionLink,
167
- ActionText,
168
129
AppNavigationItem,
169
130
CheckboxBlankCircle,
170
131
CheckboxBlankCircleOutline,
@@ -175,9 +136,6 @@ export default {
175
136
Pencil,
176
137
Undo,
177
138
},
178
- directives: {
179
- ClickOutside,
180
- },
181
139
props: {
182
140
calendar: {
183
141
type: Object,
@@ -186,14 +144,6 @@ export default {
186
144
},
187
145
data() {
188
146
return {
189
- // Rename action
190
- showRenameLabel: true,
191
- showRenameInput: false,
192
- showRenameSaving: false,
193
- // Color action
194
- showColorLabel: true,
195
- showColorInput: false,
196
- showColorSaving: false,
197
147
// share menu
198
148
shareMenuOpen: false,
199
149
// Deleting
@@ -318,6 +268,7 @@ export default {
318
268
console.error(error)
319
269
})
320
270
},
271
+
321
272
/**
322
273
* Deletes or unshares the calendar
323
274
*/
@@ -343,6 +294,7 @@ export default {
343
294
}
344
295
}, 7000)
345
296
},
297
+
346
298
/**
347
299
* Cancels the deletion of a calendar
348
300
*/
@@ -353,36 +305,7 @@ export default {
353
305
this.deleteInterval = null
354
306
this.countdown = 7
355
307
},
356
- /**
357
- * Closes the share menu
358
- * This is used with v-click-outside
359
- *
360
- * @param {Event} event The javascript click event
361
- */
362
- closeShareMenu(event) {
363
- if (!event.isTrusted) {
364
- return
365
- }
366
-
367
- if (this.$el.contains(event.target)) {
368
- this.shareMenuOpen = true
369
- return
370
- }
371
308
372
- if (event.composedPath && event.composedPath().includes(this.$el)) {
373
- this.shareMenuOpen = true
374
- return
375
- }
376
-
377
- this.shareMenuOpen = false
378
- },
379
- /**
380
- * Toggles the visibility of the share menu
381
- */
382
- toggleShareMenu() {
383
- this.shareMenuOpen = !this.shareMenuOpen
384
- console.debug('toggled share menu')
385
- },
386
309
/**
387
310
* Copies the private calendar link
388
311
* to be used with clients like Thunderbird
@@ -401,87 +324,10 @@ export default {
401
324
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
402
325
}
403
326
},
404
- /**
405
- * Opens the input-field to rename the calendar
406
- */
407
- openRenameInput() {
408
- // Hide label and show input
409
- this.showRenameLabel = false
410
- this.showRenameInput = true
411
- this.showRenameSaving = false
412
- // Reset color input if necessary
413
- this.showColorLabel = true
414
- this.showColorInput = false
415
- this.showColorSaving = false
416
- },
417
- /**
418
- * Saves the modified name of a calendar
419
- *
420
- * @param {Event} event The submit event
421
- */
422
- async saveRenameInput(event) {
423
- this.showRenameInput = false
424
- this.showRenameSaving = true
425
327
426
- const newName = event.target.querySelector('input[type=text]').value
427
- try {
428
- await this.$store.dispatch('renameCalendar', {
429
- calendar: this.calendar,
430
- newName,
431
- })
432
- this.showRenameLabel = true
433
- this.showRenameInput = false
434
- this.showRenameSaving = false
435
- } catch (error) {
436
- showInfo(this.$t('calendar', 'An error occurred, unable to rename the calendar.'))
437
- console.error(error)
438
-
439
- this.showRenameLabel = false
440
- this.showRenameInput = true
441
- this.showRenameSaving = false
442
- }
443
- },
444
328
/**
445
- * Opens the color-picker
329
+ * Open the calendar modal for this calendar item.
446
330
*/
447
- openColorInput() {
448
- // Hide label and show input
449
- this.showColorLabel = false
450
- this.showColorInput = true
451
- this.showColorSaving = false
452
- // Reset rename input if necessary
453
- this.showRenameLabel = true
454
- this.showRenameInput = false
455
- this.showRenameSaving = false
456
- },
457
- /**
458
- * Saves the modified color of a calendar
459
- *
460
- * @param {Event} event The submit event
461
- */
462
- async saveColorInput(event) {
463
- this.showColorInput = false
464
- this.showColorSaving = true
465
-
466
- const newColor = event.target.querySelector('input[type=color]').value
467
- try {
468
- await this.$store.dispatch('changeCalendarColor', {
469
- calendar: this.calendar,
470
- newColor,
471
- })
472
- this.showColorLabel = true
473
- this.showColorInput = false
474
- this.showColorSaving = false
475
- } catch (error) {
476
- showInfo(this.$t('calendar', 'An error occurred, unable to change the calendar\'s color.'))
477
- console.error(error)
478
-
479
- this.showColorLabel = false
480
- this.showColorInput = true
481
- this.showColorSaving = false
482
- }
483
- },
484
-
485
331
showEditModal() {
486
332
this.$store.commit('showEditCalendarModal', {
487
333
calendarId: this.calendar.id,
0 commit comments