Skip to content

Commit

Permalink
Merge pull request #58 from webitel/fix/routes-in-contacts
Browse files Browse the repository at this point in the history
fix: routes in communication tabs[WTEL-4296]
  • Loading branch information
dlohvinov authored Mar 19, 2024
2 parents b31995e + 534a920 commit 94a060c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/app/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,25 @@ const routes = [
children: [
{
path: 'communications',
redirect: {
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: 'variables',
name: `${CrmSections.CONTACTS}-variables`,
Expand Down
16 changes: 13 additions & 3 deletions src/modules/contacts/components/opened-contact-communications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:disabled="currentTab.value === tab.value"
:color="currentTab.value !== tab.value && 'secondary'"
wide
@click="currentTab = tab"
@click="changeTab(tab)"
>
<wt-icon
:icon="tab.icon"
Expand All @@ -23,9 +23,11 @@
</template>

<script setup>
import { computed, inject, ref } from 'vue';
import { computed, inject, ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex';
import CrmSections from '@webitel/ui-sdk/src/enums/WebitelApplications/CrmSections.enum';
import TheEmails from '../modules/emails/components/the-emails.vue';
import ThePhones from '../modules/phones/components/the-phones.vue';
Expand All @@ -43,6 +45,8 @@ const phonesNamespace = `${props.namespace}/phones`;
const store = useStore();
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
const tabs = computed(() => [
{
Expand All @@ -52,6 +56,7 @@ const tabs = computed(() => [
namespace: phonesNamespace,
icon: 'call',
channel: 'number', // must be same as comm popup channel
pathName: `${CrmSections.CONTACTS}-communications-phones`,
},
{
value: 'emails',
Expand All @@ -60,10 +65,15 @@ const tabs = computed(() => [
namespace: emailsNamespace,
icon: 'email',
channel: 'email', // must be same as comm popup channel
pathName: `${CrmSections.CONTACTS}-communications-emails`,
},
]);
const currentTab = ref(tabs.value[0]);
const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name))
function changeTab(tab) {
return router.push({ name: tab.pathName });
}
</script>

Expand Down
12 changes: 3 additions & 9 deletions src/modules/contacts/components/opened-contact-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,13 @@ const tabs = computed(() => [
},
]);
const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name));
const currentTab = computed(() => {
return tabs.value.find(({ pathName }) => route?.matched?.find(({name}) => name === pathName));
});
function changeTab(tab) {
return router.push({ name: tab.pathName });
}
function initializeTab() {
if (!currentTab.value) changeTab(tabs.value[0]);
}
onMounted(() => {
initializeTab();
});
</script>
<style lang="scss" scoped>
Expand Down

0 comments on commit 94a060c

Please sign in to comment.