From 1650566504a10d578c58008e00218783276808e2 Mon Sep 17 00:00:00 2001 From: Lera24 Date: Mon, 18 Mar 2024 16:15:39 +0200 Subject: [PATCH 1/3] fix: routes in communication tabs[WTEL-4296] --- src/app/router/index.js | 13 ++++++++++ .../opened-contact-communications.vue | 25 ++++++++++++++++--- .../components/opened-contact-tabs.vue | 7 +++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/app/router/index.js b/src/app/router/index.js index aa08eb0..571c836 100644 --- a/src/app/router/index.js +++ b/src/app/router/index.js @@ -62,9 +62,22 @@ const routes = [ children: [ { path: 'communications', + redirect: { + name: `${CrmSections.CONTACTS}-communications-phones` + }, name: `${CrmSections.CONTACTS}-communications`, component: ContactCommunications, }, + { + path: 'communications/phones', + name: `${CrmSections.CONTACTS}-communications-phones`, + component: ContactCommunications, + }, + { + path: 'communications/emails', + name: `${CrmSections.CONTACTS}-communications-emails`, + component: ContactCommunications, + }, { path: 'variables', name: `${CrmSections.CONTACTS}-variables`, diff --git a/src/modules/contacts/components/opened-contact-communications.vue b/src/modules/contacts/components/opened-contact-communications.vue index 1408980..73ac50a 100644 --- a/src/modules/contacts/components/opened-contact-communications.vue +++ b/src/modules/contacts/components/opened-contact-communications.vue @@ -7,7 +7,7 @@ :disabled="currentTab.value === tab.value" :color="currentTab.value !== tab.value && 'secondary'" wide - @click="currentTab = tab" + @click="changeTab(tab)" > diff --git a/src/modules/contacts/components/opened-contact-tabs.vue b/src/modules/contacts/components/opened-contact-tabs.vue index 27cd500..3aca3cc 100644 --- a/src/modules/contacts/components/opened-contact-tabs.vue +++ b/src/modules/contacts/components/opened-contact-tabs.vue @@ -51,7 +51,12 @@ const tabs = computed(() => [ }, ]); -const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name)); +const currentTab = computed(() => { + if(route.name.includes('communications')) { + return tabs.value.find(tab => tab.value === 'communications') + } + return tabs.value.find(({ pathName }) => pathName === route.name) +}); function changeTab(tab) { return router.push({ name: tab.pathName }); From 046b32318ce1aa2c5ad724aa75e381cb75ae370d Mon Sep 17 00:00:00 2001 From: Lera24 Date: Tue, 19 Mar 2024 12:00:53 +0200 Subject: [PATCH 2/3] fix: add children routes[WTEL-4296] --- src/app/router/index.js | 25 +++++++++++-------- .../components/opened-contact-tabs.vue | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/app/router/index.js b/src/app/router/index.js index 571c836..8269162 100644 --- a/src/app/router/index.js +++ b/src/app/router/index.js @@ -63,21 +63,24 @@ const routes = [ { path: 'communications', redirect: { - name: `${CrmSections.CONTACTS}-communications-phones` + name: `${CrmSections.CONTACTS}-communications-phones`, }, name: `${CrmSections.CONTACTS}-communications`, component: ContactCommunications, + children: [ + { + path: 'phones', + name: `${CrmSections.CONTACTS}-communications-phones`, + component: ContactCommunications, + }, + { + path: 'emails', + name: `${CrmSections.CONTACTS}-communications-emails`, + component: ContactCommunications, + }, + ], }, - { - path: 'communications/phones', - name: `${CrmSections.CONTACTS}-communications-phones`, - component: ContactCommunications, - }, - { - path: 'communications/emails', - name: `${CrmSections.CONTACTS}-communications-emails`, - component: ContactCommunications, - }, + { path: 'variables', name: `${CrmSections.CONTACTS}-variables`, diff --git a/src/modules/contacts/components/opened-contact-tabs.vue b/src/modules/contacts/components/opened-contact-tabs.vue index 3aca3cc..8150ffb 100644 --- a/src/modules/contacts/components/opened-contact-tabs.vue +++ b/src/modules/contacts/components/opened-contact-tabs.vue @@ -52,7 +52,7 @@ const tabs = computed(() => [ ]); const currentTab = computed(() => { - if(route.name.includes('communications')) { + if(route?.name?.includes('communications')) { return tabs.value.find(tab => tab.value === 'communications') } return tabs.value.find(({ pathName }) => pathName === route.name) From 534a920106d2ce9bd934c186079f162411bdede5 Mon Sep 17 00:00:00 2001 From: Lera24 Date: Tue, 19 Mar 2024 12:33:54 +0200 Subject: [PATCH 3/3] fix: finding current Tab[WTEL-4296] --- .../components/opened-contact-communications.vue | 11 +---------- .../contacts/components/opened-contact-tabs.vue | 13 +------------ 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/modules/contacts/components/opened-contact-communications.vue b/src/modules/contacts/components/opened-contact-communications.vue index 73ac50a..7bbf263 100644 --- a/src/modules/contacts/components/opened-contact-communications.vue +++ b/src/modules/contacts/components/opened-contact-communications.vue @@ -69,21 +69,12 @@ const tabs = computed(() => [ }, ]); -const currentTab = ref({}); +const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name)) function changeTab(tab) { - currentTab.value = tab; return router.push({ name: tab.pathName }); } -function initializeCommunicationsTab() { - currentTab.value = tabs.value.find(({ pathName }) => pathName === route.name) -} - -onMounted(() => { - initializeCommunicationsTab(); -}); -