fix: change tab via url
This commit is contained in:
parent
fd3f1ed8b4
commit
c1a5f6b70a
@ -950,6 +950,10 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'CRM Lead',
|
default: 'CRM Lead',
|
||||||
},
|
},
|
||||||
|
tabs: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const doc = defineModel()
|
const doc = defineModel()
|
||||||
@ -1078,7 +1082,7 @@ const defaultActions = computed(() => {
|
|||||||
{
|
{
|
||||||
icon: h(WhatsAppIcon, { class: 'h-4 w-4' }),
|
icon: h(WhatsAppIcon, { class: 'h-4 w-4' }),
|
||||||
label: __('New WhatsApp Message'),
|
label: __('New WhatsApp Message'),
|
||||||
onClick: () => (tabIndex.value = 5),
|
onClick: () => (tabIndex.value = getTabIndex('WhatsApp')),
|
||||||
condition: () => whatsappEnabled.value,
|
condition: () => whatsappEnabled.value,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -1354,6 +1358,10 @@ function scroll(hash) {
|
|||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTabIndex(name) {
|
||||||
|
return props.tabs.findIndex((tab) => tab.name === name)
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({ emailBox })
|
defineExpose({ emailBox })
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
ref="activities"
|
ref="activities"
|
||||||
doctype="CRM Lead"
|
doctype="CRM Lead"
|
||||||
:title="tab.name"
|
:title="tab.name"
|
||||||
|
:tabs="tabs"
|
||||||
v-model:reload="reload"
|
v-model:reload="reload"
|
||||||
v-model:tabIndex="tabIndex"
|
v-model:tabIndex="tabIndex"
|
||||||
v-model="lead"
|
v-model="lead"
|
||||||
@ -304,13 +305,14 @@ import {
|
|||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
call,
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
|
|
||||||
const { $dialog, makeCall } = globalStore()
|
const { $dialog, makeCall } = globalStore()
|
||||||
const { getContactByName, contacts } = contactsStore()
|
const { getContactByName, contacts } = contactsStore()
|
||||||
const { organizations } = organizationsStore()
|
const { organizations } = organizationsStore()
|
||||||
const { statusOptions, getLeadStatus } = statusesStore()
|
const { statusOptions, getLeadStatus } = statusesStore()
|
||||||
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -449,6 +451,17 @@ const tabs = computed(() => {
|
|||||||
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
|
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(tabs, (value) => {
|
||||||
|
if (value && route.params.tabName) {
|
||||||
|
let index = value.findIndex(
|
||||||
|
(tab) => tab.name.toLowerCase() === route.params.tabName.toLowerCase()
|
||||||
|
)
|
||||||
|
if (index !== -1) {
|
||||||
|
tabIndex.value = index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function validateFile(file) {
|
function validateFile(file) {
|
||||||
let extn = file.name.split('.').pop().toLowerCase()
|
let extn = file.name.split('.').pop().toLowerCase()
|
||||||
if (!['png', 'jpg', 'jpeg'].includes(extn)) {
|
if (!['png', 'jpg', 'jpeg'].includes(extn)) {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const routes = [
|
|||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
meta: { scrollPos: { top: 0, left: 0 } },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/leads/:leadId',
|
path: '/leads/:leadId/:tabName?',
|
||||||
name: 'Lead',
|
name: 'Lead',
|
||||||
component: () => import('@/pages/Lead.vue'),
|
component: () => import('@/pages/Lead.vue'),
|
||||||
props: true,
|
props: true,
|
||||||
@ -27,7 +27,7 @@ const routes = [
|
|||||||
meta: { scrollPos: { top: 0, left: 0 } },
|
meta: { scrollPos: { top: 0, left: 0 } },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/deals/:dealId',
|
path: '/deals/:dealId/:tabName?',
|
||||||
name: 'Deal',
|
name: 'Deal',
|
||||||
component: () => import('@/pages/Deal.vue'),
|
component: () => import('@/pages/Deal.vue'),
|
||||||
props: true,
|
props: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user