2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-08-25 05:34:33 +00:00
|
|
|
<router-link
|
|
|
|
:to="menuItem.toState"
|
|
|
|
tag="li"
|
|
|
|
active-class="active"
|
|
|
|
:class="computedClass"
|
|
|
|
>
|
|
|
|
<a
|
2020-03-22 06:14:40 +00:00
|
|
|
class="sub-menu-title"
|
2019-08-25 05:34:33 +00:00
|
|
|
:class="getMenuItemClass"
|
|
|
|
data-tooltip
|
|
|
|
aria-haspopup="true"
|
|
|
|
:title="menuItem.toolTip"
|
|
|
|
>
|
2020-03-22 06:14:40 +00:00
|
|
|
<div class="wrap">
|
|
|
|
<i :class="menuItem.icon" />
|
2020-04-06 16:47:07 +00:00
|
|
|
{{ $t(`SIDEBAR.${menuItem.label}`) }}
|
2020-03-22 06:14:40 +00:00
|
|
|
</div>
|
2019-08-25 05:34:33 +00:00
|
|
|
<span
|
|
|
|
v-if="showItem(menuItem)"
|
2020-03-22 06:14:40 +00:00
|
|
|
class="child-icon ion-android-add-circle"
|
2019-08-25 05:34:33 +00:00
|
|
|
@click.prevent="newLinkClick"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</a>
|
2019-08-25 05:34:33 +00:00
|
|
|
<ul v-if="menuItem.hasSubMenu" class="nested vertical menu">
|
2019-08-14 09:48:44 +00:00
|
|
|
<router-link
|
|
|
|
v-for="child in menuItem.children"
|
2019-10-29 07:20:54 +00:00
|
|
|
:key="child.id"
|
2019-08-25 05:34:33 +00:00
|
|
|
active-class="active flex-container"
|
|
|
|
tag="li"
|
|
|
|
:to="child.toState"
|
2019-08-14 09:48:44 +00:00
|
|
|
>
|
2020-10-10 17:10:11 +00:00
|
|
|
<a href="#" :class="computedChildClass(child)">
|
2020-03-22 06:14:40 +00:00
|
|
|
<div class="wrap">
|
|
|
|
<i
|
|
|
|
v-if="computedInboxClass(child)"
|
|
|
|
class="inbox-icon"
|
|
|
|
:class="computedInboxClass(child)"
|
2020-06-25 15:34:03 +00:00
|
|
|
/>
|
|
|
|
<span
|
|
|
|
v-if="child.color"
|
|
|
|
class="label-color--display"
|
|
|
|
:style="{ backgroundColor: child.color }"
|
|
|
|
/>
|
2020-10-10 17:10:11 +00:00
|
|
|
<div
|
|
|
|
:title="computedChildTitle(child)"
|
|
|
|
:class="computedChildClass(child)"
|
|
|
|
>
|
|
|
|
{{ child.label }}
|
|
|
|
</div>
|
2020-03-22 06:14:40 +00:00
|
|
|
</div>
|
2020-02-19 05:00:34 +00:00
|
|
|
</a>
|
2019-08-14 09:48:44 +00:00
|
|
|
</router-link>
|
|
|
|
</ul>
|
|
|
|
</router-link>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
import router from '../../routes';
|
2020-05-26 17:08:48 +00:00
|
|
|
import adminMixin from '../../mixins/isAdmin';
|
2020-08-05 12:16:17 +00:00
|
|
|
import { INBOX_TYPES } from 'shared/mixins/inboxMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-10-04 17:27:11 +00:00
|
|
|
const getInboxClassByType = (type, phoneNumber) => {
|
2020-02-19 05:00:34 +00:00
|
|
|
switch (type) {
|
|
|
|
case INBOX_TYPES.WEB:
|
|
|
|
return 'ion-earth';
|
|
|
|
|
|
|
|
case INBOX_TYPES.FB:
|
|
|
|
return 'ion-social-facebook';
|
|
|
|
|
|
|
|
case INBOX_TYPES.TWITTER:
|
|
|
|
return 'ion-social-twitter';
|
|
|
|
|
2020-04-05 16:41:27 +00:00
|
|
|
case INBOX_TYPES.TWILIO:
|
2020-10-04 17:27:11 +00:00
|
|
|
return phoneNumber.startsWith('whatsapp')
|
|
|
|
? 'ion-social-whatsapp-outline'
|
|
|
|
: 'ion-android-textsms';
|
2020-04-05 16:41:27 +00:00
|
|
|
|
2020-07-21 06:45:24 +00:00
|
|
|
case INBOX_TYPES.API:
|
|
|
|
return 'ion-cloud';
|
|
|
|
|
|
|
|
case INBOX_TYPES.EMAIL:
|
|
|
|
return 'ion-email';
|
|
|
|
|
2020-02-19 05:00:34 +00:00
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2020-05-26 17:08:48 +00:00
|
|
|
mixins: [adminMixin],
|
2019-08-25 05:34:33 +00:00
|
|
|
props: {
|
|
|
|
menuItem: {
|
|
|
|
type: Object,
|
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
activeInbox: 'getSelectedInbox',
|
|
|
|
}),
|
|
|
|
getMenuItemClass() {
|
2019-08-25 05:34:33 +00:00
|
|
|
return this.menuItem.cssClass
|
|
|
|
? `side-menu ${this.menuItem.cssClass}`
|
|
|
|
: 'side-menu';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
computedClass() {
|
|
|
|
// If active Inbox is present
|
|
|
|
// donot highlight conversations
|
|
|
|
if (this.activeInbox) return ' ';
|
|
|
|
|
2019-08-25 05:34:33 +00:00
|
|
|
if (
|
|
|
|
this.$store.state.route.name === 'inbox_conversation' &&
|
|
|
|
this.menuItem.toStateName === 'home'
|
|
|
|
) {
|
2019-08-14 09:48:44 +00:00
|
|
|
return 'active';
|
|
|
|
}
|
|
|
|
return ' ';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
computedInboxClass(child) {
|
2020-10-04 17:27:11 +00:00
|
|
|
const { type, phoneNumber } = child;
|
|
|
|
const classByType = getInboxClassByType(type, phoneNumber);
|
2020-02-19 05:00:34 +00:00
|
|
|
return classByType;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-10-10 17:10:11 +00:00
|
|
|
computedChildClass(child) {
|
|
|
|
if (!child.truncateLabel) return '';
|
|
|
|
return 'text-truncate';
|
|
|
|
},
|
|
|
|
computedChildTitle(child) {
|
|
|
|
if (!child.truncateLabel) return false;
|
|
|
|
return child.label;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
newLinkClick() {
|
|
|
|
router.push({ name: 'settings_inbox_new', params: { page: 'new' } });
|
|
|
|
},
|
|
|
|
showItem(item) {
|
2020-05-26 17:08:48 +00:00
|
|
|
return this.isAdmin && item.newLink !== undefined;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-03-22 06:14:40 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-06-25 15:34:03 +00:00
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
2020-03-22 06:14:40 +00:00
|
|
|
.sub-menu-title {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
2020-06-25 15:34:03 +00:00
|
|
|
|
|
|
|
.wrap {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.label-color--display {
|
|
|
|
border-radius: $space-smaller;
|
|
|
|
height: $space-normal;
|
|
|
|
margin-right: $space-small;
|
2020-10-10 17:10:11 +00:00
|
|
|
min-width: $space-normal;
|
2020-06-25 15:34:03 +00:00
|
|
|
width: $space-normal;
|
|
|
|
}
|
2020-03-22 06:14:40 +00:00
|
|
|
</style>
|