fix: remove the scroll behaviour in listview
This commit is contained in:
parent
610e6a0a90
commit
3dc45c3c8c
@ -18,7 +18,6 @@ const routes = [
|
|||||||
path: '/leads/view/:viewType?',
|
path: '/leads/view/:viewType?',
|
||||||
name: 'Leads',
|
name: 'Leads',
|
||||||
component: () => import('@/pages/Leads.vue'),
|
component: () => import('@/pages/Leads.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/leads/:leadId',
|
path: '/leads/:leadId',
|
||||||
@ -31,7 +30,6 @@ const routes = [
|
|||||||
path: '/deals/view/:viewType?',
|
path: '/deals/view/:viewType?',
|
||||||
name: 'Deals',
|
name: 'Deals',
|
||||||
component: () => import('@/pages/Deals.vue'),
|
component: () => import('@/pages/Deals.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/deals/:dealId',
|
path: '/deals/:dealId',
|
||||||
@ -56,7 +54,6 @@ const routes = [
|
|||||||
path: '/contacts/view/:viewType?',
|
path: '/contacts/view/:viewType?',
|
||||||
name: 'Contacts',
|
name: 'Contacts',
|
||||||
component: () => import('@/pages/Contacts.vue'),
|
component: () => import('@/pages/Contacts.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/contacts/:contactId',
|
path: '/contacts/:contactId',
|
||||||
@ -69,7 +66,6 @@ const routes = [
|
|||||||
path: '/organizations/view/:viewType?',
|
path: '/organizations/view/:viewType?',
|
||||||
name: 'Organizations',
|
name: 'Organizations',
|
||||||
component: () => import('@/pages/Organizations.vue'),
|
component: () => import('@/pages/Organizations.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/organizations/:organizationId',
|
path: '/organizations/:organizationId',
|
||||||
@ -82,14 +78,12 @@ const routes = [
|
|||||||
path: '/call-logs/view/:viewType?',
|
path: '/call-logs/view/:viewType?',
|
||||||
name: 'Call Logs',
|
name: 'Call Logs',
|
||||||
component: () => import('@/pages/CallLogs.vue'),
|
component: () => import('@/pages/CallLogs.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
alias: '/email-templates',
|
alias: '/email-templates',
|
||||||
path: '/email-templates/view/:viewType?',
|
path: '/email-templates/view/:viewType?',
|
||||||
name: 'Email Templates',
|
name: 'Email Templates',
|
||||||
component: () => import('@/pages/EmailTemplates.vue'),
|
component: () => import('@/pages/EmailTemplates.vue'),
|
||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/email-templates/:emailTemplateId',
|
path: '/email-templates/:emailTemplateId',
|
||||||
@ -108,29 +102,9 @@ const handleMobileView = (componentName) => {
|
|||||||
return window.innerWidth < 768 ? `Mobile${componentName}` : componentName
|
return window.innerWidth < 768 ? `Mobile${componentName}` : componentName
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollBehavior = (to, from, savedPosition) => {
|
|
||||||
if (to.name === from.name) {
|
|
||||||
to.meta?.scrollPos && (to.meta.scrollPos.top = 0)
|
|
||||||
return { left: 0, top: 0 }
|
|
||||||
}
|
|
||||||
const scrollpos = to.meta?.scrollPos || { left: 0, top: 0 }
|
|
||||||
|
|
||||||
if (scrollpos.top > 0) {
|
|
||||||
setTimeout(() => {
|
|
||||||
let el = document.querySelector('#list-rows')
|
|
||||||
el.scrollTo({
|
|
||||||
top: scrollpos.top,
|
|
||||||
left: scrollpos.left,
|
|
||||||
behavior: 'smooth',
|
|
||||||
})
|
|
||||||
}, 300)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let router = createRouter({
|
let router = createRouter({
|
||||||
history: createWebHistory('/crm'),
|
history: createWebHistory('/crm'),
|
||||||
routes,
|
routes,
|
||||||
scrollBehavior,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
@ -138,10 +112,6 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
|
|
||||||
isLoggedIn && (await userResource.promise)
|
isLoggedIn && (await userResource.promise)
|
||||||
|
|
||||||
if (from.meta?.scrollPos) {
|
|
||||||
from.meta.scrollPos.top = document.querySelector('#list-rows')?.scrollTop
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to.name === 'Home' && isLoggedIn) {
|
if (to.name === 'Home' && isLoggedIn) {
|
||||||
next({ name: 'Leads' })
|
next({ name: 'Leads' })
|
||||||
} else if (!isLoggedIn) {
|
} else if (!isLoggedIn) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user