Skip to content

Commit a131088

Browse files
committed
fixup! Redesign calendar sharing
1 parent 668f953 commit a131088

File tree

2 files changed

+154
-198
lines changed

2 files changed

+154
-198
lines changed

src/components/AppNavigation/CalendarList/CalendarListItem.vue

+14-168
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
-->
2323

2424
<template>
25-
<AppNavigationItem v-click-outside="closeShareMenu"
26-
:loading="calendar.loading"
25+
<AppNavigationItem :loading="calendar.loading"
2726
:aria-description="descriptionAppNavigationItem"
2827
:title="calendar.displayName || $t('calendar', 'Untitled calendar')"
29-
:class="{deleted: !!deleteTimeout, disabled: !calendar.enabled, 'open-sharing': shareMenuOpen}"
28+
:class="{deleted: !!deleteTimeout, disabled: !calendar.enabled}"
3029
@click.prevent.stop="toggleEnabled">
3130
<template #icon>
3231
<CheckboxBlankCircle v-if="calendar.enabled"
@@ -37,53 +36,19 @@
3736
:fill-color="calendar.color" />
3837
</template>
3938

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+
4044
<template #actions>
4145
<template v-if="!deleteTimeout">
4246
<ActionButton @click.prevent.stop="showEditModal">
4347
<template #icon>
4448
<Pencil :size="20" decorative />
4549
</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') }}
7351
</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>
8752
<ActionButton @click.stop.prevent="copyLink">
8853
<template #icon>
8954
<LinkVariant :size="20" decorative />
@@ -113,7 +78,7 @@
11378
</ActionButton>
11479
</template>
11580

116-
<template v-if="!!deleteTimeout">
81+
<template v-if="deleteTimeout">
11782
<ActionButton v-if="calendar.isSharedWithMe"
11883
@click.prevent.stop="cancelDeleteCalendar">
11984
<template #icon>
@@ -134,14 +99,11 @@
13499
</template>
135100

136101
<script>
102+
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
137103
import ActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
138-
import ActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
139104
import ActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
140-
import ActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
141105
import AppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js'
142-
import ClickOutside from 'vue-click-outside'
143106
import {
144-
showInfo,
145107
showSuccess,
146108
showError,
147109
} from '@nextcloud/dialogs'
@@ -161,10 +123,9 @@ import Undo from 'vue-material-design-icons/Undo.vue'
161123
export default {
162124
name: 'CalendarListItem',
163125
components: {
126+
NcAvatar,
164127
ActionButton,
165-
ActionInput,
166128
ActionLink,
167-
ActionText,
168129
AppNavigationItem,
169130
CheckboxBlankCircle,
170131
CheckboxBlankCircleOutline,
@@ -175,9 +136,6 @@ export default {
175136
Pencil,
176137
Undo,
177138
},
178-
directives: {
179-
ClickOutside,
180-
},
181139
props: {
182140
calendar: {
183141
type: Object,
@@ -186,14 +144,6 @@ export default {
186144
},
187145
data() {
188146
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,
197147
// share menu
198148
shareMenuOpen: false,
199149
// Deleting
@@ -318,6 +268,7 @@ export default {
318268
console.error(error)
319269
})
320270
},
271+
321272
/**
322273
* Deletes or unshares the calendar
323274
*/
@@ -343,6 +294,7 @@ export default {
343294
}
344295
}, 7000)
345296
},
297+
346298
/**
347299
* Cancels the deletion of a calendar
348300
*/
@@ -353,36 +305,7 @@ export default {
353305
this.deleteInterval = null
354306
this.countdown = 7
355307
},
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-
}
371308

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-
},
386309
/**
387310
* Copies the private calendar link
388311
* to be used with clients like Thunderbird
@@ -401,87 +324,10 @@ export default {
401324
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
402325
}
403326
},
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
425327

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-
},
444328
/**
445-
* Opens the color-picker
329+
* Open the calendar modal for this calendar item.
446330
*/
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-
485331
showEditModal() {
486332
this.$store.commit('showEditCalendarModal', {
487333
calendarId: this.calendar.id,

0 commit comments

Comments
 (0)