fix: removed isSidebarCollapsed from global and use absolute positioning to position notification panel
This commit is contained in:
parent
f95f211dbe
commit
f94c566b70
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="flex h-full flex-col justify-between transition-all duration-300 ease-in-out"
|
class="relative flex h-full flex-col justify-between transition-all duration-300 ease-in-out"
|
||||||
:class="isSidebarCollapsed ? 'w-12' : 'w-56'"
|
:class="isSidebarCollapsed ? 'w-12' : 'w-56'"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@ -91,6 +91,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
|
<Notifications />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -108,18 +109,16 @@ import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
|
|||||||
import CollapseSidebar from '@/components/Icons/CollapseSidebar.vue'
|
import CollapseSidebar from '@/components/Icons/CollapseSidebar.vue'
|
||||||
import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue'
|
import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue'
|
||||||
import SidebarLink from '@/components/SidebarLink.vue'
|
import SidebarLink from '@/components/SidebarLink.vue'
|
||||||
|
import Notifications from '@/components/Notifications.vue'
|
||||||
import { viewsStore } from '@/stores/views'
|
import { viewsStore } from '@/stores/views'
|
||||||
import { notificationsStore } from '@/stores/notifications'
|
import { notificationsStore } from '@/stores/notifications'
|
||||||
import { globalStore } from '@/stores/global'
|
import { useStorage } from '@vueuse/core'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
const { getPinnedViews, getPublicViews } = viewsStore()
|
const { getPinnedViews, getPublicViews } = viewsStore()
|
||||||
const { toggle: toggleNotificationPanel } = notificationsStore()
|
const { toggle: toggleNotificationPanel } = notificationsStore()
|
||||||
|
|
||||||
const isSidebarCollapsed = computed({
|
const isSidebarCollapsed = useStorage('isSidebarCollapsed', false)
|
||||||
get: () => globalStore().isSidebarCollapsed,
|
|
||||||
set: (value) => globalStore().setIsSidebarCollapsed(value),
|
|
||||||
})
|
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
<div class="h-full border-r bg-gray-50">
|
<div class="h-full border-r bg-gray-50">
|
||||||
<AppSidebar />
|
<AppSidebar />
|
||||||
</div>
|
</div>
|
||||||
<Notifications />
|
|
||||||
<div class="flex-1 flex flex-col h-full overflow-auto">
|
<div class="flex-1 flex flex-col h-full overflow-auto">
|
||||||
<AppHeader />
|
<AppHeader />
|
||||||
<slot />
|
<slot />
|
||||||
@ -12,6 +11,5 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import AppSidebar from '@/components/Layouts/AppSidebar.vue'
|
import AppSidebar from '@/components/Layouts/AppSidebar.vue'
|
||||||
import Notifications from '@/components/Notifications.vue'
|
|
||||||
import AppHeader from '@/components/Layouts/AppHeader.vue'
|
import AppHeader from '@/components/Layouts/AppHeader.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -2,51 +2,58 @@
|
|||||||
<div
|
<div
|
||||||
v-if="notificationsStore().visible"
|
v-if="notificationsStore().visible"
|
||||||
ref="target"
|
ref="target"
|
||||||
class="fixed z-20 h-screen overflow-auto bg-white transition-all duration-300 ease-in-out"
|
class="absolute left-[102%] z-20 h-screen bg-white transition-all duration-300 ease-in-out"
|
||||||
:style="{
|
:style="{
|
||||||
'box-shadow': '8px 0px 8px rgba(0, 0, 0, 0.1)',
|
'box-shadow': '8px 0px 8px rgba(0, 0, 0, 0.1)',
|
||||||
'max-width': '350px',
|
'max-width': '350px',
|
||||||
'min-width': '350px',
|
'min-width': '350px',
|
||||||
left: isSidebarCollapsed ? '3rem' : '14rem',
|
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div
|
<div class="flex h-screen flex-col">
|
||||||
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-5 py-2.5"
|
<div
|
||||||
>
|
class="z-20 flex items-center justify-between border-b bg-white px-5 py-2.5"
|
||||||
<span class="text-lg font-medium">Notifications</span>
|
|
||||||
<span>
|
|
||||||
<Button
|
|
||||||
theme="blue"
|
|
||||||
variant="ghost"
|
|
||||||
@click="() => notificationsStore().mark_as_read.reload()"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<MarkAsDoneIcon class="h-4 w-4" />
|
|
||||||
</template>
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
theme="gray"
|
|
||||||
variant="ghost"
|
|
||||||
@click="() => toggleNotificationPanel()"
|
|
||||||
>
|
|
||||||
<template #icon>
|
|
||||||
<FeatherIcon name="x" class="h-4 w-4" />
|
|
||||||
</template>
|
|
||||||
</Button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="divide-y text-base">
|
|
||||||
<RouterLink
|
|
||||||
v-for="n in notificationsStore().allNotifications"
|
|
||||||
:key="n.comment"
|
|
||||||
:to="getRoute(n)"
|
|
||||||
class="flex cursor-pointer items-start gap-3.5 px-5 py-2.5 hover:bg-gray-100"
|
|
||||||
@click="mark_as_read(n.comment)"
|
|
||||||
>
|
>
|
||||||
<UserAvatar :user="n.from_user.name" size="md" />
|
<div class="text-base font-medium">Notifications</div>
|
||||||
<span>
|
<div class="flex gap-1">
|
||||||
<div class="mb-2 leading-5">
|
<Tooltip text="Mark all as read">
|
||||||
<span class="space-x-1 text-gray-700">
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
@click="() => notificationsStore().mark_as_read.reload()"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<MarkAsDoneIcon class="h-4 w-4" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip text="Close">
|
||||||
|
<Button variant="ghost" @click="() => toggleNotificationPanel()">
|
||||||
|
<template #icon>
|
||||||
|
<FeatherIcon name="x" class="h-4 w-4" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="notificationsStore().allNotifications?.length"
|
||||||
|
class="divide-y overflow-auto text-base"
|
||||||
|
>
|
||||||
|
<RouterLink
|
||||||
|
v-for="n in notificationsStore().allNotifications"
|
||||||
|
:key="n.comment"
|
||||||
|
:to="getRoute(n)"
|
||||||
|
class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100"
|
||||||
|
@click="mark_as_read(n.comment)"
|
||||||
|
>
|
||||||
|
<div class="mt-1 flex items-center gap-2.5">
|
||||||
|
<div
|
||||||
|
class="h-1.5 w-1.5 rounded-full"
|
||||||
|
:class="[n.read ? 'bg-transparent' : 'bg-gray-900']"
|
||||||
|
/>
|
||||||
|
<UserAvatar :user="n.from_user.name" size="lg" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mb-2 space-x-1 leading-5 text-gray-700">
|
||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{ n.from_user.full_name }}
|
{{ n.from_user.full_name }}
|
||||||
</span>
|
</span>
|
||||||
@ -54,29 +61,35 @@
|
|||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{ n.reference_name }}
|
{{ n.reference_name }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<div class="text-sm text-gray-600">
|
<div class="text-sm text-gray-600">
|
||||||
{{ timeAgo(n.creation) }}
|
{{ timeAgo(n.creation) }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!n.read" class="h-1.5 w-1.5 rounded-full bg-gray-900" />
|
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</RouterLink>
|
||||||
</RouterLink>
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="flex flex-1 flex-col items-center justify-center gap-2"
|
||||||
|
>
|
||||||
|
<NotificationsIcon class="h-20 w-20 text-gray-300" />
|
||||||
|
<div class="text-lg font-medium text-gray-500">
|
||||||
|
No new notifications
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import MarkAsDoneIcon from '@/components/Icons/MarkAsDoneIcon.vue'
|
import MarkAsDoneIcon from '@/components/Icons/MarkAsDoneIcon.vue'
|
||||||
|
import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue'
|
||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import { notificationsStore } from '@/stores/notifications'
|
import { notificationsStore } from '@/stores/notifications'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { timeAgo } from '@/utils'
|
import { timeAgo } from '@/utils'
|
||||||
import { onClickOutside } from '@vueuse/core'
|
import { onClickOutside } from '@vueuse/core'
|
||||||
import { ref, computed } from 'vue'
|
import { Tooltip } from 'frappe-ui'
|
||||||
|
import { ref } from 'vue'
|
||||||
const isSidebarCollapsed = computed(() => globalStore().isSidebarCollapsed)
|
|
||||||
|
|
||||||
const target = ref(null)
|
const target = ref(null)
|
||||||
onClickOutside(
|
onClickOutside(
|
||||||
|
|||||||
@ -7,7 +7,6 @@ export const globalStore = defineStore('crm-global', () => {
|
|||||||
const { $dialog } = app.appContext.config.globalProperties
|
const { $dialog } = app.appContext.config.globalProperties
|
||||||
|
|
||||||
let twilioEnabled = ref(false)
|
let twilioEnabled = ref(false)
|
||||||
let isSidebarCollapsed = useStorage('isSidebarCollapsed', false)
|
|
||||||
let callMethod = () => {}
|
let callMethod = () => {}
|
||||||
|
|
||||||
function setTwilioEnabled(value) {
|
function setTwilioEnabled(value) {
|
||||||
@ -22,15 +21,9 @@ export const globalStore = defineStore('crm-global', () => {
|
|||||||
callMethod(number)
|
callMethod(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setIsSidebarCollapsed(value) {
|
|
||||||
isSidebarCollapsed.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
$dialog,
|
$dialog,
|
||||||
twilioEnabled,
|
twilioEnabled,
|
||||||
isSidebarCollapsed,
|
|
||||||
setIsSidebarCollapsed,
|
|
||||||
makeCall,
|
makeCall,
|
||||||
setTwilioEnabled,
|
setTwilioEnabled,
|
||||||
setMakeCall,
|
setMakeCall,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user