first commit
This commit is contained in:
302
resources/js/views/apps/email/ComposeDialog.vue
Normal file
302
resources/js/views/apps/email/ComposeDialog.vue
Normal file
@@ -0,0 +1,302 @@
|
||||
<script setup>
|
||||
import { Image } from '@tiptap/extension-image'
|
||||
import { Link } from '@tiptap/extension-link'
|
||||
import { Placeholder } from '@tiptap/extension-placeholder'
|
||||
import { Underline } from '@tiptap/extension-underline'
|
||||
import { StarterKit } from '@tiptap/starter-kit'
|
||||
import {
|
||||
EditorContent,
|
||||
useEditor,
|
||||
} from '@tiptap/vue-3'
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const to = ref('')
|
||||
const cc = ref('')
|
||||
const bcc = ref('')
|
||||
const subject = ref('')
|
||||
const message = ref('')
|
||||
const emailCc = ref(false)
|
||||
const emailBcc = ref(false)
|
||||
|
||||
const resetValues = () => {
|
||||
to.value = subject.value = message.value = ''
|
||||
}
|
||||
|
||||
const editor = useEditor({
|
||||
content: '',
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Image,
|
||||
Placeholder.configure({ placeholder: 'Message' }),
|
||||
Underline,
|
||||
Link.configure({ openOnClick: false }),
|
||||
],
|
||||
})
|
||||
|
||||
const setLink = () => {
|
||||
const previousUrl = editor.value?.getAttributes('link').href
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
const url = window.prompt('URL', previousUrl)
|
||||
|
||||
// cancelled
|
||||
if (url === null)
|
||||
return
|
||||
|
||||
// empty
|
||||
if (url === '') {
|
||||
editor.value?.chain().focus().extendMarkRange('link').unsetLink().run()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// update link
|
||||
editor.value?.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
|
||||
}
|
||||
|
||||
const addImage = () => {
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
const url = window.prompt('URL')
|
||||
if (url)
|
||||
editor.value?.chain().focus().setImage({ src: url }).run()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VCard
|
||||
class="email-compose-dialog"
|
||||
elevation="24"
|
||||
max-width="30vw"
|
||||
>
|
||||
<VCardItem class="py-3">
|
||||
<VCardTitle class="text-medium-emphasis">
|
||||
Compose Mail
|
||||
</VCardTitle>
|
||||
|
||||
<template #append>
|
||||
<IconBtn @click="$emit('close')">
|
||||
<VIcon icon="ri-subtract-line" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn @click="$emit('close'); resetValues()">
|
||||
<VIcon icon="ri-close-line" />
|
||||
</IconBtn>
|
||||
</template>
|
||||
</VCardItem>
|
||||
|
||||
<div class="pe-5">
|
||||
<VTextField
|
||||
v-model="to"
|
||||
density="compact"
|
||||
>
|
||||
<template #prepend-inner>
|
||||
<div class="text-disabled font-weight-medium">
|
||||
To:
|
||||
</div>
|
||||
</template>
|
||||
<template #append>
|
||||
<span class="cursor-pointer text-medium-emphasis">
|
||||
<span @click="emailCc = !emailCc">Cc</span>
|
||||
<span class="mx-1">|</span>
|
||||
<span @click="emailBcc = !emailBcc">Bcc</span>
|
||||
</span>
|
||||
</template>
|
||||
</VTextField>
|
||||
</div>
|
||||
|
||||
<VExpandTransition>
|
||||
<div v-if="emailCc">
|
||||
<VDivider />
|
||||
|
||||
<VTextField
|
||||
v-model="cc"
|
||||
density="compact"
|
||||
>
|
||||
<template #prepend-inner>
|
||||
<div class="text-disabled font-weight-medium">
|
||||
Cc:
|
||||
</div>
|
||||
</template>
|
||||
</VTextField>
|
||||
</div>
|
||||
</VExpandTransition>
|
||||
|
||||
<VExpandTransition>
|
||||
<div v-if="emailBcc">
|
||||
<VDivider />
|
||||
|
||||
<VTextField
|
||||
v-model="bcc"
|
||||
density="compact"
|
||||
>
|
||||
<template #prepend-inner>
|
||||
<div class="text-disabled font-weight-medium">
|
||||
Bcc:
|
||||
</div>
|
||||
</template>
|
||||
</VTextField>
|
||||
</div>
|
||||
</VExpandTransition>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<VTextField
|
||||
v-model="subject"
|
||||
density="compact"
|
||||
>
|
||||
<template #prepend-inner>
|
||||
<div class="text-disabled font-weight-medium">
|
||||
Subject:
|
||||
</div>
|
||||
</template>
|
||||
</VTextField>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<!-- 👉 Tiptap editor -->
|
||||
<div class="tiptap-editor-wrapper">
|
||||
<div
|
||||
v-if="editor"
|
||||
class="d-flex flex-wrap gap-x-1 px-4 py-2"
|
||||
>
|
||||
<IconBtn
|
||||
rounded
|
||||
:color="editor.isActive('bold') ? 'primary' : ''"
|
||||
:variant="editor.isActive('bold') ? 'tonal' : 'text'"
|
||||
@click="editor.chain().focus().toggleBold().run()"
|
||||
>
|
||||
<VIcon icon="ri-bold" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
:color="editor.isActive('underline') ? 'primary' : ''"
|
||||
:variant="editor.isActive('underline') ? 'tonal' : 'text'"
|
||||
@click="editor.commands.toggleUnderline()"
|
||||
>
|
||||
<VIcon icon="ri-underline" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
:color="editor.isActive('italic') ? 'primary' : ''"
|
||||
:variant="editor.isActive('italic') ? 'tonal' : 'text'"
|
||||
@click="editor.chain().focus().toggleItalic().run()"
|
||||
>
|
||||
<VIcon icon="ri-italic" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
:color="editor.isActive('bulletList') ? 'primary' : ''"
|
||||
:variant="editor.isActive('bulletList') ? 'tonal' : 'text'"
|
||||
@click="editor.chain().focus().toggleBulletList().run()"
|
||||
>
|
||||
<VIcon icon="ri-list-check" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
:color="editor.isActive('orderedList') ? 'primary' : ''"
|
||||
:variant="editor.isActive('orderedList') ? 'tonal' : 'text'"
|
||||
@click="editor.chain().focus().toggleOrderedList().run()"
|
||||
>
|
||||
<VIcon icon="ri-list-ordered-2" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
@click="setLink"
|
||||
>
|
||||
<VIcon icon="ri-links-line" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn
|
||||
rounded
|
||||
@click="addImage"
|
||||
>
|
||||
<VIcon icon="ri-image-line" />
|
||||
</IconBtn>
|
||||
</div>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<div class="mx-5">
|
||||
<EditorContent :editor="editor" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-center px-5 py-4 gap-4">
|
||||
<VBtn append-icon="ri-send-plane-line">
|
||||
Send
|
||||
<VMenu activator="parent">
|
||||
<VList :items="['Schedule Mail', 'Save Draft']" />
|
||||
</VMenu>
|
||||
</VBtn>
|
||||
|
||||
<IconBtn>
|
||||
<VIcon icon="ri-attachment-2" />
|
||||
</IconBtn>
|
||||
|
||||
<VSpacer />
|
||||
|
||||
<IconBtn>
|
||||
<VIcon icon="ri-more-2-line" />
|
||||
</IconBtn>
|
||||
|
||||
<IconBtn @click="$emit('close'); resetValues()">
|
||||
<VIcon icon="ri-delete-bin-7-line" />
|
||||
</IconBtn>
|
||||
</div>
|
||||
</VCard>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.email-compose-dialog {
|
||||
z-index: 910 !important;
|
||||
|
||||
.v-field--prepended {
|
||||
padding-inline-start: 20px;
|
||||
}
|
||||
|
||||
.v-card-item {
|
||||
background-color: rgba(var(--v-theme-on-surface), var(--v-hover-opacity));
|
||||
}
|
||||
|
||||
.v-textarea .v-field {
|
||||
--v-field-padding-start: 20px;
|
||||
}
|
||||
|
||||
.v-field__outline {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ProseMirror {
|
||||
block-size: 150px;
|
||||
overflow-y: auto;
|
||||
padding-block: .5rem;
|
||||
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-block-end: 0;
|
||||
}
|
||||
|
||||
p.is-editor-empty:first-child::before {
|
||||
block-size: 0;
|
||||
color: #adb5bd;
|
||||
content: attr(data-placeholder);
|
||||
float: inline-start;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
ul,ol{
|
||||
padding-inline: 1.125rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
213
resources/js/views/apps/email/EmailLeftSidebarContent.vue
Normal file
213
resources/js/views/apps/email/EmailLeftSidebarContent.vue
Normal file
@@ -0,0 +1,213 @@
|
||||
<script setup>
|
||||
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
|
||||
|
||||
const emit = defineEmits(['toggleComposeDialogVisibility'])
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const folders = [
|
||||
{
|
||||
title: 'Inbox',
|
||||
prependIcon: 'ri-mail-line',
|
||||
to: { name: 'apps-email' },
|
||||
badge: {
|
||||
content: '21',
|
||||
color: 'primary',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Sent',
|
||||
prependIcon: 'ri-send-plane-line',
|
||||
to: {
|
||||
name: 'apps-email-filter',
|
||||
params: { filter: 'sent' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Draft',
|
||||
prependIcon: 'ri-edit-box-line',
|
||||
to: {
|
||||
name: 'apps-email-filter',
|
||||
params: { filter: 'draft' },
|
||||
},
|
||||
badge: {
|
||||
content: '2',
|
||||
color: 'warning',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Starred',
|
||||
prependIcon: 'ri-star-line',
|
||||
to: {
|
||||
name: 'apps-email-filter',
|
||||
params: { filter: 'starred' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Spam',
|
||||
prependIcon: 'ri-spam-2-line',
|
||||
to: {
|
||||
name: 'apps-email-filter',
|
||||
params: { filter: 'spam' },
|
||||
},
|
||||
badge: {
|
||||
content: '4',
|
||||
color: 'error',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Trash',
|
||||
prependIcon: 'ri-delete-bin-7-line',
|
||||
to: {
|
||||
name: 'apps-email-filter',
|
||||
params: { filter: 'trashed' },
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const labels = [
|
||||
{
|
||||
title: 'Personal',
|
||||
color: 'success',
|
||||
to: {
|
||||
name: 'apps-email-label',
|
||||
params: { label: 'personal' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Company',
|
||||
color: 'primary',
|
||||
to: {
|
||||
name: 'apps-email-label',
|
||||
params: { label: 'company' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Important',
|
||||
color: 'warning',
|
||||
to: {
|
||||
name: 'apps-email-label',
|
||||
params: { label: 'important' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Private',
|
||||
color: 'error',
|
||||
to: {
|
||||
name: 'apps-email-label',
|
||||
params: { label: 'private' },
|
||||
},
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="d-flex flex-column h-100">
|
||||
<!-- 👉 Compose -->
|
||||
<div class="pa-5">
|
||||
<VBtn
|
||||
block
|
||||
@click="$emit('toggleComposeDialogVisibility')"
|
||||
>
|
||||
Compose
|
||||
</VBtn>
|
||||
</div>
|
||||
|
||||
<!-- 👉 Folders -->
|
||||
<PerfectScrollbar
|
||||
:options="{ wheelPropagation: false }"
|
||||
class="h-100 pt-4"
|
||||
>
|
||||
<ul class="email-filters-labels">
|
||||
<RouterLink
|
||||
v-for="folder in folders"
|
||||
:key="folder.title"
|
||||
v-slot="{ isActive, href, navigate }"
|
||||
class="d-flex align-center cursor-pointer"
|
||||
:to="folder.to"
|
||||
custom
|
||||
>
|
||||
<li
|
||||
v-bind="$attrs"
|
||||
:href="href"
|
||||
:class="isActive && 'email-filter-active text-primary'"
|
||||
class="d-flex align-center cursor-pointer"
|
||||
@click="navigate"
|
||||
>
|
||||
<VIcon
|
||||
:icon="folder.prependIcon"
|
||||
class="me-2"
|
||||
size="20"
|
||||
/>
|
||||
<span>{{ folder.title }}</span>
|
||||
|
||||
<VSpacer />
|
||||
|
||||
<VChip
|
||||
v-if="folder.badge?.content"
|
||||
size="x-small"
|
||||
:color="folder.badge.color"
|
||||
>
|
||||
{{ folder.badge.content }}
|
||||
</VChip>
|
||||
</li>
|
||||
</RouterLink>
|
||||
|
||||
<!-- 👉 Labels -->
|
||||
<li class="text-sm d-block text-uppercase text-disabled mt-9 mb-4">
|
||||
LABELS
|
||||
</li>
|
||||
<RouterLink
|
||||
v-for="label in labels"
|
||||
:key="label.title"
|
||||
v-slot="{ isActive, href, navigate }"
|
||||
class="d-flex align-center"
|
||||
:to="label.to"
|
||||
custom
|
||||
>
|
||||
<li
|
||||
v-bind="$attrs"
|
||||
:href="href"
|
||||
:class="isActive && 'email-label-active text-primary'"
|
||||
class="cursor-pointer"
|
||||
@click="navigate"
|
||||
>
|
||||
<VIcon
|
||||
:color="label.color"
|
||||
icon="ri-circle-fill"
|
||||
size="12"
|
||||
class="me-2"
|
||||
/>
|
||||
<span>{{ label.title }}</span>
|
||||
</li>
|
||||
</RouterLink>
|
||||
</ul>
|
||||
</PerfectScrollbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.email-filters-labels {
|
||||
> li {
|
||||
position: relative;
|
||||
margin-block-end: 4px;
|
||||
padding-block: 4px;
|
||||
padding-inline: 20px;
|
||||
}
|
||||
|
||||
.email-filter-active,
|
||||
.email-label-active {
|
||||
&::after {
|
||||
position: absolute;
|
||||
background: currentcolor;
|
||||
block-size: 100%;
|
||||
content: "";
|
||||
inline-size: 3px;
|
||||
inset-block-start: 0;
|
||||
inset-inline-start: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
487
resources/js/views/apps/email/EmailView.vue
Normal file
487
resources/js/views/apps/email/EmailView.vue
Normal file
@@ -0,0 +1,487 @@
|
||||
<script setup>
|
||||
import { Image } from '@tiptap/extension-image'
|
||||
import { Link } from '@tiptap/extension-link'
|
||||
import { Placeholder } from '@tiptap/extension-placeholder'
|
||||
import { Underline } from '@tiptap/extension-underline'
|
||||
import { StarterKit } from '@tiptap/starter-kit'
|
||||
import {
|
||||
EditorContent,
|
||||
useEditor,
|
||||
} from '@tiptap/vue-3'
|
||||
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
|
||||
import { useEmail } from '@/views/apps/email/useEmail'
|
||||
|
||||
const props = defineProps({
|
||||
email: {
|
||||
type: null,
|
||||
required: true,
|
||||
},
|
||||
emailMeta: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits([
|
||||
'refresh',
|
||||
'navigated',
|
||||
'close',
|
||||
'trash',
|
||||
'unread',
|
||||
'read',
|
||||
'star',
|
||||
'unstar',
|
||||
])
|
||||
|
||||
const { updateEmailLabels } = useEmail()
|
||||
const { labels, resolveLabelColor, emailMoveToFolderActions, shallShowMoveToActionFor, moveSelectedEmailTo } = useEmail()
|
||||
|
||||
const handleMoveMailsTo = action => {
|
||||
moveSelectedEmailTo(action, [props.email.id])
|
||||
emit('refresh')
|
||||
emit('close')
|
||||
}
|
||||
|
||||
const updateMailLabel = async label => {
|
||||
await updateEmailLabels([props.email.id], label)
|
||||
emit('refresh')
|
||||
}
|
||||
|
||||
const editor = useEditor({
|
||||
content: '',
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Image,
|
||||
Placeholder.configure({ placeholder: 'Write a Comment...' }),
|
||||
Underline,
|
||||
Link.configure({ openOnClick: false }),
|
||||
],
|
||||
})
|
||||
|
||||
const setLink = () => {
|
||||
const previousUrl = editor.value?.getAttributes('link').href
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
const url = window.prompt('URL', previousUrl)
|
||||
|
||||
// cancelled
|
||||
if (url === null)
|
||||
return
|
||||
|
||||
// empty
|
||||
if (url === '') {
|
||||
editor.value?.chain().focus().extendMarkRange('link').unsetLink().run()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// update link
|
||||
editor.value?.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
|
||||
}
|
||||
|
||||
const addImage = () => {
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
const url = window.prompt('URL')
|
||||
if (url)
|
||||
editor.value?.chain().focus().setImage({ src: url }).run()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- ℹ️ calc(100% - 256px) => 265px is left sidebar width -->
|
||||
<VNavigationDrawer
|
||||
temporary
|
||||
:model-value="!!props.email"
|
||||
location="right"
|
||||
:scrim="false"
|
||||
floating
|
||||
class="email-view"
|
||||
>
|
||||
<template v-if="props.email">
|
||||
<!-- 👉 header -->
|
||||
|
||||
<div class="email-view-header d-flex align-center px-5 py-4">
|
||||
<IconBtn
|
||||
class="me-2 flip-in-rtl"
|
||||
@click="$emit('close')"
|
||||
>
|
||||
<VIcon icon="ri-arrow-left-s-line" />
|
||||
</IconBtn>
|
||||
|
||||
<div class="d-flex align-center flex-wrap flex-grow-1 overflow-hidden gap-2">
|
||||
<h6 class="text-h6 font-weight-regular text-truncate">
|
||||
{{ props.email.subject }}
|
||||
</h6>
|
||||
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<VChip
|
||||
v-for="label in props.email.labels"
|
||||
:key="label"
|
||||
:color="resolveLabelColor(label)"
|
||||
size="small"
|
||||
class="text-capitalize flex-shrink-0"
|
||||
>
|
||||
{{ label }}
|
||||
</VChip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-center gap-2">
|
||||
<IconBtn
|
||||
variant="plain"
|
||||
:disabled="!props.emailMeta.hasPreviousEmail"
|
||||
class="flip-in-rtl"
|
||||
@click="$emit('navigated', 'previous')"
|
||||
>
|
||||
<VIcon icon="ri-arrow-left-s-line" />
|
||||
</IconBtn>
|
||||
<IconBtn
|
||||
variant="plain"
|
||||
class="flip-in-rtl"
|
||||
:disabled="!props.emailMeta.hasNextEmail"
|
||||
@click="$emit('navigated', 'next')"
|
||||
>
|
||||
<VIcon icon="ri-arrow-right-s-line" />
|
||||
</IconBtn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<!-- 👉 Action bar -->
|
||||
<div class="email-view-action-bar d-flex align-center text-medium-emphasis gap-1 px-5">
|
||||
<!-- Trash -->
|
||||
<IconBtn
|
||||
v-show="!props.email.isDeleted"
|
||||
@click="$emit('trash'); $emit('close')"
|
||||
>
|
||||
<VIcon icon="ri-delete-bin-7-line" />
|
||||
<VTooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
Delete Mail
|
||||
</VTooltip>
|
||||
</IconBtn>
|
||||
|
||||
<!-- Read/Unread -->
|
||||
<IconBtn @click.stop="$emit('unread'); $emit('close')">
|
||||
<VIcon icon="ri-mail-line" />
|
||||
<VTooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
Mark as Unread
|
||||
</VTooltip>
|
||||
</IconBtn>
|
||||
|
||||
<!-- Move to folder -->
|
||||
<IconBtn>
|
||||
<VIcon icon="ri-folder-line" />
|
||||
<VTooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
Move to
|
||||
</VTooltip>
|
||||
|
||||
<VMenu activator="parent">
|
||||
<VList density="compact">
|
||||
<template
|
||||
v-for="moveTo in emailMoveToFolderActions"
|
||||
:key="moveTo.title"
|
||||
>
|
||||
<VListItem
|
||||
:class="shallShowMoveToActionFor(moveTo.action) ? 'd-flex' : 'd-none'"
|
||||
class="align-center"
|
||||
href="#"
|
||||
@click="handleMoveMailsTo(moveTo.action)"
|
||||
>
|
||||
<template #prepend>
|
||||
<VIcon
|
||||
:icon="moveTo.icon"
|
||||
class="me-2"
|
||||
size="20"
|
||||
/>
|
||||
</template>
|
||||
<VListItemTitle class="text-capitalize">
|
||||
{{ moveTo.action }}
|
||||
</VListItemTitle>
|
||||
</VListItem>
|
||||
</template>
|
||||
</VList>
|
||||
</VMenu>
|
||||
</IconBtn>
|
||||
|
||||
<!-- Update labels -->
|
||||
<IconBtn>
|
||||
<VIcon icon="ri-price-tag-3-line" />
|
||||
<VTooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
Label
|
||||
</VTooltip>
|
||||
|
||||
<VMenu activator="parent">
|
||||
<VList density="compact">
|
||||
<VListItem
|
||||
v-for="label in labels"
|
||||
:key="label.title"
|
||||
href="#"
|
||||
@click.stop="updateMailLabel(label.title)"
|
||||
>
|
||||
<template #prepend>
|
||||
<VBadge
|
||||
inline
|
||||
:color="resolveLabelColor(label.title)"
|
||||
dot
|
||||
/>
|
||||
</template>
|
||||
<VListItemTitle class="ms-2 text-capitalize">
|
||||
{{ label.title }}
|
||||
</VListItemTitle>
|
||||
</VListItem>
|
||||
</VList>
|
||||
</VMenu>
|
||||
</IconBtn>
|
||||
|
||||
<VSpacer />
|
||||
|
||||
<!-- Star/Unstar -->
|
||||
<IconBtn
|
||||
:color="props.email.isStarred ? 'warning' : 'default'"
|
||||
@click="props.email?.isStarred ? $emit('unstar') : $emit('star')"
|
||||
>
|
||||
<VIcon icon="ri-star-line" />
|
||||
</IconBtn>
|
||||
|
||||
<!-- Dots vertical -->
|
||||
<MoreBtn />
|
||||
</div>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<!-- 👉 Mail Content -->
|
||||
<PerfectScrollbar
|
||||
tag="div"
|
||||
class="mail-content-container flex-grow-1"
|
||||
:options="{ wheelPropagation: false }"
|
||||
>
|
||||
<VCard class="ma-6 mb-4">
|
||||
<VCardText class="mail-header">
|
||||
<div class="d-flex align-start">
|
||||
<VAvatar
|
||||
size="38"
|
||||
class="me-3"
|
||||
>
|
||||
<VImg
|
||||
:src="props.email.from.avatar"
|
||||
:alt="props.email.from.name"
|
||||
/>
|
||||
</VAvatar>
|
||||
|
||||
<div class="d-flex flex-wrap flex-grow-1 overflow-hidden">
|
||||
<div class="text-truncate">
|
||||
<h6 class="text-h6 font-weight-regular text-truncate">
|
||||
{{ props.email.from.name }}
|
||||
</h6>
|
||||
<p class="text-body-2 mb-0">
|
||||
{{ props.email.from.email }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<VSpacer />
|
||||
|
||||
<div class="d-flex align-center">
|
||||
<span class="text-disabled me-4">{{ formatDate(props.email.time) }}</span>
|
||||
<IconBtn v-show="props.email.attachments.length">
|
||||
<VIcon icon="ri-attachment-2" />
|
||||
</IconBtn>
|
||||
</div>
|
||||
</div>
|
||||
<MoreBtn class="align-self-sm-center" />
|
||||
</div>
|
||||
</VCardText>
|
||||
|
||||
<VDivider />
|
||||
|
||||
<VCardText>
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<div
|
||||
class="text-base"
|
||||
v-html="props.email.message"
|
||||
/>
|
||||
<!-- eslint-enable -->
|
||||
</VCardText>
|
||||
|
||||
<template v-if="props.email.attachments.length">
|
||||
<VDivider />
|
||||
|
||||
<VCardText class="d-flex flex-column gap-y-4">
|
||||
<span>Attachments</span>
|
||||
<div
|
||||
v-for="attachment in props.email.attachments"
|
||||
:key="attachment.fileName"
|
||||
class="d-flex align-center"
|
||||
>
|
||||
<VImg
|
||||
:src="attachment.thumbnail"
|
||||
:alt="attachment.fileName"
|
||||
aspect-ratio="1"
|
||||
max-height="24"
|
||||
max-width="24"
|
||||
class="me-2"
|
||||
/>
|
||||
<span>{{ attachment.fileName }}</span>
|
||||
</div>
|
||||
</VCardText>
|
||||
</template>
|
||||
</VCard>
|
||||
|
||||
<VCard class="ma-6">
|
||||
<VCardText>
|
||||
<h6 class="text-h6 font-weight-regular mb-6">
|
||||
Reply to Ross Geller
|
||||
</h6>
|
||||
<!-- 👉 Tiptap editor -->
|
||||
<div class="tiptap-editor-wrapper">
|
||||
<div
|
||||
v-if="editor"
|
||||
class="d-flex flex-wrap gap-x-2 mb-6"
|
||||
>
|
||||
<VIcon
|
||||
icon="ri-bold"
|
||||
:color="editor.isActive('bold') ? 'primary' : ''"
|
||||
size="20"
|
||||
@click="editor.chain().focus().toggleBold().run()"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
:color="editor.isActive('underline') ? 'primary' : ''"
|
||||
icon="ri-underline"
|
||||
size="20"
|
||||
@click="editor.commands.toggleUnderline()"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
:color="editor.isActive('italic') ? 'primary' : ''"
|
||||
icon="ri-italic"
|
||||
size="20"
|
||||
@click="editor.chain().focus().toggleItalic().run()"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
:color="editor.isActive('bulletList') ? 'primary' : ''"
|
||||
icon="ri-list-check"
|
||||
size="20"
|
||||
@click="editor.chain().focus().toggleBulletList().run()"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
:color="editor.isActive('orderedList') ? 'primary' : ''"
|
||||
icon="ri-list-ordered-2"
|
||||
size="20"
|
||||
@click="editor.chain().focus().toggleOrderedList().run()"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
icon="ri-links-line"
|
||||
size="20"
|
||||
@click="setLink"
|
||||
/>
|
||||
|
||||
<VIcon
|
||||
icon="ri-image-line"
|
||||
size="20"
|
||||
@click="addImage"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<EditorContent :editor="editor" />
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-center justify-end mt-6">
|
||||
<VBtn
|
||||
color="secondary"
|
||||
variant="plain"
|
||||
class="me-4"
|
||||
>
|
||||
<VIcon icon="ri-attachment-2" />
|
||||
<span>Attachments</span>
|
||||
</VBtn>
|
||||
<VBtn>
|
||||
<span>Send</span>
|
||||
<VIcon icon="ri-send-plane-line" />
|
||||
</VBtn>
|
||||
</div>
|
||||
</VCardText>
|
||||
</VCard>
|
||||
</PerfectScrollbar>
|
||||
</template>
|
||||
</VNavigationDrawer>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.email-view {
|
||||
inline-size: 100% !important;
|
||||
|
||||
@media only screen and (min-width: 1280px) {
|
||||
inline-size: calc(100% - 256px) !important;
|
||||
}
|
||||
|
||||
.v-navigation-drawer__content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ProseMirror {
|
||||
padding: 0;
|
||||
block-size: 100px;
|
||||
overflow-y: auto;
|
||||
|
||||
p {
|
||||
margin-block-end: 0;
|
||||
}
|
||||
|
||||
p.is-editor-empty:first-child::before {
|
||||
block-size: 0;
|
||||
color: #adb5bd;
|
||||
content: attr(data-placeholder);
|
||||
float: inline-start;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
ul,ol{
|
||||
padding-inline: 1.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
.is-active {
|
||||
border-color: rgba(var(--v-theme-primary), var(--v-border-opacity)) !important;
|
||||
background-color: rgba(var(--v-theme-primary), var(--v-activated-opacity));
|
||||
color: rgb(var(--v-theme-primary));
|
||||
}
|
||||
|
||||
.ProseMirror-focused{
|
||||
outline: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.email-view-action-bar {
|
||||
min-block-size: 54px;
|
||||
}
|
||||
|
||||
.mail-content-container {
|
||||
background-color: rgb(var(--v-theme-on-background), var(--v-hover-opacity));
|
||||
|
||||
.mail-header {
|
||||
min-block-size: 84px;
|
||||
}
|
||||
|
||||
.v-card {
|
||||
border: 1px solid rgba(var(--v-theme-on-surface), var(--v-border-opacity));
|
||||
}
|
||||
}
|
||||
</style>
|
94
resources/js/views/apps/email/useEmail.js
Normal file
94
resources/js/views/apps/email/useEmail.js
Normal file
@@ -0,0 +1,94 @@
|
||||
export const useEmail = () => {
|
||||
const route = useRoute('apps-email-filter')
|
||||
|
||||
const updateEmails = async (ids, data) => {
|
||||
await $api('apps/email', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ids, data }),
|
||||
})
|
||||
}
|
||||
|
||||
const updateEmailLabels = async (ids, label) => {
|
||||
await $api('/apps/email', {
|
||||
method: 'POST',
|
||||
body: { ids, label },
|
||||
})
|
||||
}
|
||||
|
||||
const emailMoveToFolderActions = [
|
||||
{ action: 'inbox', icon: 'ri-mail-line' },
|
||||
{ action: 'spam', icon: 'ri-spam-2-line' },
|
||||
{ action: 'trash', icon: 'ri-delete-bin-line' },
|
||||
]
|
||||
|
||||
const labels = [
|
||||
{
|
||||
title: 'personal',
|
||||
color: 'success',
|
||||
},
|
||||
{
|
||||
title: 'company',
|
||||
color: 'primary',
|
||||
},
|
||||
{
|
||||
title: 'important',
|
||||
color: 'warning',
|
||||
},
|
||||
{
|
||||
title: 'private',
|
||||
color: 'error',
|
||||
},
|
||||
]
|
||||
|
||||
const resolveLabelColor = label => {
|
||||
if (label === 'personal')
|
||||
return 'success'
|
||||
if (label === 'company')
|
||||
return 'primary'
|
||||
if (label === 'important')
|
||||
return 'warning'
|
||||
if (label === 'private')
|
||||
return 'error'
|
||||
|
||||
return 'secondary'
|
||||
}
|
||||
|
||||
const shallShowMoveToActionFor = action => {
|
||||
if (action === 'trash')
|
||||
return route.params.filter !== 'trashed'
|
||||
else if (action === 'inbox')
|
||||
return !(route.params.filter === undefined || route.params.filter === 'sent' || route.params.filter === 'draft')
|
||||
else if (action === 'spam')
|
||||
return !(route.params.filter === 'spam' || route.params.filter === 'sent' || route.params.filter === 'draft')
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
const moveSelectedEmailTo = (action, selectedEmails) => {
|
||||
const dataToUpdate = {}
|
||||
if (action === 'inbox') {
|
||||
if (route.params.filter === 'trashed')
|
||||
dataToUpdate.isDeleted = false
|
||||
dataToUpdate.folder = 'inbox'
|
||||
}
|
||||
else if (action === 'spam') {
|
||||
if (route.params.filter === 'trashed')
|
||||
dataToUpdate.isDeleted = false
|
||||
dataToUpdate.folder = 'spam'
|
||||
}
|
||||
else if (action === 'trash') {
|
||||
dataToUpdate.isDeleted = true
|
||||
}
|
||||
updateEmails(selectedEmails, dataToUpdate)
|
||||
}
|
||||
|
||||
return {
|
||||
labels,
|
||||
resolveLabelColor,
|
||||
shallShowMoveToActionFor,
|
||||
emailMoveToFolderActions,
|
||||
moveSelectedEmailTo,
|
||||
updateEmails,
|
||||
updateEmailLabels,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user