fix: after attaching change tab to attachments

This commit is contained in:
Shariq Ansari 2024-10-17 17:41:55 +05:30
parent dc1c2d36a0
commit 497ee46f33
4 changed files with 33 additions and 5 deletions

View File

@ -443,7 +443,12 @@
v-model="showFilesUploader"
:doctype="doctype"
:docname="doc.data.name"
@after="() => all_activities.reload()"
@after="
() => {
all_activities.reload()
changeTabTo('attachments')
}
"
/>
</template>
<script setup>
@ -532,6 +537,13 @@ const showFilesUploader = ref(false)
const title = computed(() => props.tabs?.[tabIndex.value]?.name || 'Activity')
const changeTabTo = (tabName) => {
const tabNames = props.tabs?.map((tab) => tab.name?.toLowerCase())
const index = tabNames?.indexOf(tabName)
if (index == -1) return
tabIndex.value = index
}
const all_activities = createResource({
url: 'crm.api.activities.get_activities',
params: { name: doc.value.data.name },

View File

@ -7,6 +7,12 @@ export function useActiveTabManager(tabs, storageKey) {
const route = useRoute()
const router = useRouter()
const changeTabTo = (tabName) => {
let index = findTabIndex(tabName)
if (index == -1) return
tabIndex.value = index
}
const preserveLastVisitedTab = useDebounceFn((tabName) => {
activeTab.value = tabName.toLowerCase()
}, 300)
@ -78,5 +84,5 @@ export function useActiveTabManager(tabs, storageKey) {
tabIndex.value = getActiveTab()
})
return { tabIndex }
return { tabIndex, changeTabTo }
}

View File

@ -309,7 +309,12 @@
v-model="showFilesUploader"
doctype="CRM Deal"
:docname="deal.data.name"
@after="() => activities?.all_activities?.reload()"
@after="
() => {
activities?.all_activities?.reload()
changeTabTo('attachments')
}
"
/>
</template>
<script setup>

View File

@ -282,7 +282,12 @@
v-model="showFilesUploader"
doctype="CRM Lead"
:docname="lead.data.name"
@after="() => activities?.all_activities?.reload()"
@after="
() => {
activities?.all_activities?.reload()
changeTabTo('attachments')
}
"
/>
</template>
<script setup>
@ -526,7 +531,7 @@ const tabs = computed(() => {
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
})
const { tabIndex } = useActiveTabManager(tabs, 'lastLeadTab')
const { tabIndex, changeTabTo } = useActiveTabManager(tabs, 'lastLeadTab')
watch(tabs, (value) => {
if (value && route.params.tabName) {