2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<aside class="sidebar animated shrink columns">
|
|
|
|
<div class="logo">
|
2019-08-25 14:29:28 +00:00
|
|
|
<router-link :to="dashboardPath" replace>
|
2020-05-11 20:01:40 +00:00
|
|
|
<img :src="globalConfig.logo" :alt="globalConfig.installationName" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="main-nav">
|
|
|
|
<transition-group name="menu-list" tag="ul" class="menu vertical">
|
|
|
|
<sidebar-item
|
2019-08-25 14:29:28 +00:00
|
|
|
v-for="item in accessibleMenuItems"
|
|
|
|
:key="item.toState"
|
2019-08-14 09:48:44 +00:00
|
|
|
:menu-item="item"
|
|
|
|
/>
|
2019-12-28 16:26:42 +00:00
|
|
|
<sidebar-item
|
|
|
|
v-if="shouldShowInboxes"
|
|
|
|
:key="inboxSection.toState"
|
|
|
|
:menu-item="inboxSection"
|
|
|
|
/>
|
2020-06-25 15:34:03 +00:00
|
|
|
<sidebar-item
|
|
|
|
v-if="shouldShowInboxes"
|
|
|
|
:key="labelSection.toState"
|
|
|
|
:menu-item="labelSection"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</transition-group>
|
|
|
|
</div>
|
2019-11-24 13:39:17 +00:00
|
|
|
|
2020-10-02 05:46:12 +00:00
|
|
|
<div class="bottom-nav">
|
|
|
|
<availability-status />
|
|
|
|
</div>
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="bottom-nav">
|
|
|
|
<transition name="menu-slide">
|
2019-08-25 14:29:28 +00:00
|
|
|
<div
|
|
|
|
v-if="showOptionsMenu"
|
|
|
|
v-on-clickaway="showOptions"
|
|
|
|
class="dropdown-pane top"
|
|
|
|
>
|
2019-08-14 09:48:44 +00:00
|
|
|
<ul class="vertical dropdown menu">
|
2020-07-26 07:24:50 +00:00
|
|
|
<li v-if="showChangeAccountOption">
|
2020-05-26 17:08:48 +00:00
|
|
|
<button
|
|
|
|
class="button clear change-accounts--button"
|
|
|
|
@click="changeAccount"
|
|
|
|
>
|
|
|
|
{{ $t('SIDEBAR_ITEMS.CHANGE_ACCOUNTS') }}
|
|
|
|
</button>
|
|
|
|
</li>
|
2020-02-16 11:50:38 +00:00
|
|
|
<li>
|
2020-03-09 17:57:10 +00:00
|
|
|
<router-link :to="`/app/accounts/${accountId}/profile/settings`">
|
2020-04-06 16:47:07 +00:00
|
|
|
{{ $t('SIDEBAR_ITEMS.PROFILE_SETTINGS') }}
|
2020-02-16 11:50:38 +00:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="#" @click.prevent="logout()">
|
2020-04-06 16:47:07 +00:00
|
|
|
{{ $t('SIDEBAR_ITEMS.LOGOUT') }}
|
2020-02-16 11:50:38 +00:00
|
|
|
</a>
|
|
|
|
</li>
|
2019-08-14 09:48:44 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</transition>
|
2020-10-02 05:46:12 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="current-user" @click.prevent="showOptions()">
|
2020-07-04 06:12:47 +00:00
|
|
|
<thumbnail
|
|
|
|
:src="currentUser.avatar_url"
|
2020-07-27 16:49:26 +00:00
|
|
|
:username="currentUserAvailableName"
|
2020-07-04 06:12:47 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="current-user--data">
|
2019-08-25 14:29:28 +00:00
|
|
|
<h3 class="current-user--name">
|
2020-07-27 16:49:26 +00:00
|
|
|
{{ currentUserAvailableName }}
|
2019-08-25 14:29:28 +00:00
|
|
|
</h3>
|
2020-09-20 16:49:34 +00:00
|
|
|
<h5 v-if="currentRole" class="current-user--role">
|
|
|
|
{{ $t(`AGENT_MGMT.AGENT_TYPES.${currentRole.toUpperCase()}`) }}
|
2019-08-25 14:29:28 +00:00
|
|
|
</h5>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2020-05-26 17:08:48 +00:00
|
|
|
<span class="current-user--options icon ion-android-more-vertical" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-26 17:08:48 +00:00
|
|
|
<woot-modal
|
|
|
|
:show="showAccountModal"
|
|
|
|
:on-close="onClose"
|
|
|
|
class="account-selector--modal"
|
|
|
|
>
|
|
|
|
<woot-modal-header
|
|
|
|
:header-title="$t('SIDEBAR_ITEMS.CHANGE_ACCOUNTS')"
|
|
|
|
:header-content="$t('SIDEBAR_ITEMS.SELECTOR_SUBTITLE')"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
v-for="account in currentUser.accounts"
|
|
|
|
:key="account.id"
|
|
|
|
class="account-selector"
|
|
|
|
>
|
|
|
|
<a :href="`/app/accounts/${account.id}/dashboard`">
|
|
|
|
<i v-if="account.id === accountId" class="ion ion-ios-checkmark" />
|
|
|
|
<label :for="account.name" class="account--details">
|
|
|
|
<div class="account--name">{{ account.name }}</div>
|
|
|
|
<div class="account--role">{{ account.role }}</div>
|
|
|
|
</label>
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-07-26 07:24:50 +00:00
|
|
|
<div
|
|
|
|
v-if="globalConfig.createNewAccountFromDashboard"
|
|
|
|
class="modal-footer delete-item"
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
class="button success large expanded nice"
|
|
|
|
@click="createAccount"
|
|
|
|
>
|
|
|
|
{{ $t('CREATE_ACCOUNT.NEW_ACCOUNT') }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</woot-modal>
|
|
|
|
|
|
|
|
<woot-modal
|
|
|
|
:show="showCreateAccountModal"
|
|
|
|
:on-close="onCloseCreate"
|
|
|
|
class="account-selector--modal"
|
|
|
|
>
|
|
|
|
<div class="column content-box">
|
|
|
|
<woot-modal-header
|
|
|
|
:header-title="$t('CREATE_ACCOUNT.NEW_ACCOUNT')"
|
|
|
|
:header-content="$t('CREATE_ACCOUNT.SELECTOR_SUBTITLE')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<form class="row" @submit.prevent="addAccount()">
|
|
|
|
<div class="medium-12 columns">
|
|
|
|
<label :class="{ error: $v.accountName.$error }">
|
|
|
|
{{ $t('CREATE_ACCOUNT.FORM.NAME.LABEL') }}
|
|
|
|
<input
|
|
|
|
v-model.trim="accountName"
|
|
|
|
type="text"
|
|
|
|
:placeholder="$t('CREATE_ACCOUNT.FORM.NAME.PLACEHOLDER')"
|
|
|
|
@input="$v.accountName.$touch"
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer medium-12 columns">
|
|
|
|
<div class="medium-12 columns">
|
|
|
|
<woot-submit-button
|
|
|
|
:disabled="
|
|
|
|
$v.accountName.$invalid ||
|
|
|
|
$v.accountName.$invalid ||
|
|
|
|
uiFlags.isCreating
|
|
|
|
"
|
|
|
|
:button-text="$t('CREATE_ACCOUNT.FORM.SUBMIT')"
|
|
|
|
:loading="uiFlags.isCreating"
|
|
|
|
button-class="large expanded"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2020-05-26 17:08:48 +00:00
|
|
|
</woot-modal>
|
2019-08-14 09:48:44 +00:00
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
|
|
|
|
|
|
|
import adminMixin from '../../mixins/isAdmin';
|
|
|
|
import Auth from '../../api/auth';
|
|
|
|
import SidebarItem from './SidebarItem';
|
2020-10-02 05:46:12 +00:00
|
|
|
import AvailabilityStatus from './AvailabilityStatus';
|
2019-08-25 14:29:28 +00:00
|
|
|
import { frontendURL } from '../../helper/URLHelper';
|
2019-11-05 04:45:09 +00:00
|
|
|
import Thumbnail from '../widgets/Thumbnail';
|
2020-05-26 17:08:48 +00:00
|
|
|
import { getSidebarItems } from '../../i18n/default-sidebar';
|
2020-07-26 07:24:50 +00:00
|
|
|
import { required, minLength } from 'vuelidate/lib/validators';
|
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-12-28 16:26:42 +00:00
|
|
|
components: {
|
|
|
|
SidebarItem,
|
|
|
|
Thumbnail,
|
2020-10-02 05:46:12 +00:00
|
|
|
AvailabilityStatus,
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2020-07-26 07:24:50 +00:00
|
|
|
mixins: [clickaway, adminMixin, alertMixin],
|
2019-08-14 09:48:44 +00:00
|
|
|
props: {
|
2019-08-25 14:29:28 +00:00
|
|
|
route: {
|
|
|
|
type: String,
|
2019-12-28 16:26:42 +00:00
|
|
|
default: '',
|
2019-08-25 14:29:28 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showOptionsMenu: false,
|
2020-05-26 17:08:48 +00:00
|
|
|
showAccountModal: false,
|
2020-07-26 07:24:50 +00:00
|
|
|
showCreateAccountModal: false,
|
|
|
|
accountName: '',
|
|
|
|
vertical: 'bottom',
|
|
|
|
horizontal: 'center',
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
2020-07-26 07:24:50 +00:00
|
|
|
validations: {
|
|
|
|
accountName: {
|
|
|
|
required,
|
|
|
|
minLength: minLength(1),
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2020-05-11 20:01:40 +00:00
|
|
|
currentUser: 'getCurrentUser',
|
|
|
|
globalConfig: 'globalConfig/get',
|
2019-12-28 16:26:42 +00:00
|
|
|
inboxes: 'inboxes/getInboxes',
|
2020-05-26 17:08:48 +00:00
|
|
|
accountId: 'getCurrentAccountId',
|
|
|
|
currentRole: 'getCurrentRole',
|
2020-07-26 07:24:50 +00:00
|
|
|
uiFlags: 'agents/getUIFlags',
|
2020-06-25 15:34:03 +00:00
|
|
|
accountLabels: 'labels/getLabelsOnSidebar',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
2020-07-27 16:49:26 +00:00
|
|
|
currentUserAvailableName() {
|
|
|
|
const { available_name: availableName } = this.currentUser;
|
|
|
|
return availableName;
|
|
|
|
},
|
2020-07-26 07:24:50 +00:00
|
|
|
showChangeAccountOption() {
|
|
|
|
if (this.globalConfig.createNewAccountFromDashboard) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return this.currentUser.accounts.length > 1;
|
|
|
|
},
|
2020-05-26 17:08:48 +00:00
|
|
|
sidemenuItems() {
|
|
|
|
return getSidebarItems(this.accountId);
|
|
|
|
},
|
2019-08-25 14:29:28 +00:00
|
|
|
accessibleMenuItems() {
|
2019-08-14 09:48:44 +00:00
|
|
|
// get all keys in menuGroup
|
2020-05-26 17:08:48 +00:00
|
|
|
const groupKey = Object.keys(this.sidemenuItems);
|
2019-08-25 14:29:28 +00:00
|
|
|
|
|
|
|
let menuItems = [];
|
2019-08-14 09:48:44 +00:00
|
|
|
// Iterate over menuGroup to find the correct group
|
|
|
|
for (let i = 0; i < groupKey.length; i += 1) {
|
2020-05-26 17:08:48 +00:00
|
|
|
const groupItem = this.sidemenuItems[groupKey[i]];
|
2019-08-14 09:48:44 +00:00
|
|
|
// Check if current route is included
|
2019-12-28 16:26:42 +00:00
|
|
|
const isRouteIncluded = groupItem.routes.includes(this.currentRoute);
|
2019-08-14 09:48:44 +00:00
|
|
|
if (isRouteIncluded) {
|
2019-08-25 14:29:28 +00:00
|
|
|
menuItems = Object.values(groupItem.menuItems);
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2019-11-24 13:39:17 +00:00
|
|
|
return this.filterMenuItemsByRole(menuItems);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
currentRoute() {
|
|
|
|
return this.$store.state.route.name;
|
|
|
|
},
|
|
|
|
shouldShowInboxes() {
|
2020-05-26 17:08:48 +00:00
|
|
|
return this.sidemenuItems.common.routes.includes(this.currentRoute);
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
|
|
|
inboxSection() {
|
|
|
|
return {
|
|
|
|
icon: 'ion-folder',
|
2020-04-06 16:47:07 +00:00
|
|
|
label: 'INBOXES',
|
2019-12-28 16:26:42 +00:00
|
|
|
hasSubMenu: true,
|
|
|
|
newLink: true,
|
|
|
|
key: 'inbox',
|
|
|
|
cssClass: 'menu-title align-justify',
|
2020-03-09 17:57:10 +00:00
|
|
|
toState: frontendURL(`accounts/${this.accountId}/settings/inboxes`),
|
2019-12-28 16:26:42 +00:00
|
|
|
toStateName: 'settings_inbox_list',
|
|
|
|
children: this.inboxes.map(inbox => ({
|
|
|
|
id: inbox.id,
|
|
|
|
label: inbox.name,
|
2020-03-09 17:57:10 +00:00
|
|
|
toState: frontendURL(`accounts/${this.accountId}/inbox/${inbox.id}`),
|
2020-02-19 05:00:34 +00:00
|
|
|
type: inbox.channel_type,
|
2020-10-04 17:27:11 +00:00
|
|
|
phoneNumber: inbox.phone_number,
|
2019-12-28 16:26:42 +00:00
|
|
|
})),
|
|
|
|
};
|
|
|
|
},
|
2020-06-25 15:34:03 +00:00
|
|
|
labelSection() {
|
|
|
|
return {
|
|
|
|
icon: 'ion-pound',
|
|
|
|
label: 'LABELS',
|
|
|
|
hasSubMenu: true,
|
|
|
|
key: 'label',
|
|
|
|
cssClass: 'menu-title align-justify',
|
|
|
|
toState: frontendURL(`accounts/${this.accountId}/settings/labels`),
|
|
|
|
toStateName: 'labels_list',
|
|
|
|
children: this.accountLabels.map(label => ({
|
|
|
|
id: label.id,
|
|
|
|
label: label.title,
|
|
|
|
color: label.color,
|
2020-10-10 17:10:11 +00:00
|
|
|
truncateLabel: true,
|
2020-06-25 15:34:03 +00:00
|
|
|
toState: frontendURL(
|
|
|
|
`accounts/${this.accountId}/label/${label.title}`
|
|
|
|
),
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
},
|
2019-11-24 13:39:17 +00:00
|
|
|
dashboardPath() {
|
2020-03-09 17:57:10 +00:00
|
|
|
return frontendURL(`accounts/${this.accountId}/dashboard`);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
mounted() {
|
|
|
|
this.$store.dispatch('inboxes/get');
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2019-11-24 13:39:17 +00:00
|
|
|
filterMenuItemsByRole(menuItems) {
|
2020-05-26 17:08:48 +00:00
|
|
|
if (!this.currentRole) {
|
2020-02-16 11:50:38 +00:00
|
|
|
return [];
|
|
|
|
}
|
2019-11-24 13:39:17 +00:00
|
|
|
return menuItems.filter(
|
|
|
|
menuItem =>
|
2020-05-26 17:08:48 +00:00
|
|
|
window.roleWiseRoutes[this.currentRole].indexOf(
|
|
|
|
menuItem.toStateName
|
|
|
|
) > -1
|
2019-11-24 13:39:17 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
logout() {
|
|
|
|
Auth.logout();
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
showOptions() {
|
|
|
|
this.showOptionsMenu = !this.showOptionsMenu;
|
|
|
|
},
|
2020-05-26 17:08:48 +00:00
|
|
|
changeAccount() {
|
|
|
|
this.showAccountModal = true;
|
|
|
|
},
|
|
|
|
onClose() {
|
|
|
|
this.showAccountModal = false;
|
|
|
|
},
|
2020-07-26 07:24:50 +00:00
|
|
|
createAccount() {
|
|
|
|
this.showAccountModal = false;
|
|
|
|
this.showCreateAccountModal = true;
|
|
|
|
},
|
|
|
|
onCloseCreate() {
|
|
|
|
this.showCreateAccountModal = false;
|
|
|
|
},
|
|
|
|
async addAccount() {
|
|
|
|
try {
|
|
|
|
const account_id = await this.$store.dispatch('accounts/create', {
|
|
|
|
account_name: this.accountName,
|
|
|
|
});
|
|
|
|
this.onClose();
|
|
|
|
this.showAlert(this.$t('CREATE_ACCOUNT.API.SUCCESS_MESSAGE'));
|
|
|
|
window.location = `/app/accounts/${account_id}/dashboard`;
|
|
|
|
} catch (error) {
|
|
|
|
if (error.response.status === 422) {
|
|
|
|
this.showAlert(this.$t('CREATE_ACCOUNT.API.EXIST_MESSAGE'));
|
|
|
|
} else {
|
|
|
|
this.showAlert(this.$t('CREATE_ACCOUNT.API.ERROR_MESSAGE'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-05-26 17:08:48 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.account-selector--modal {
|
|
|
|
.modal-container {
|
|
|
|
width: 40rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.page-top-bar {
|
|
|
|
padding-bottom: $space-two;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.change-accounts--button.button {
|
|
|
|
font-weight: $font-weight-normal;
|
|
|
|
font-size: $font-size-small;
|
|
|
|
padding: $space-small $space-one;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dropdown-pane {
|
|
|
|
li {
|
|
|
|
a {
|
|
|
|
padding: $space-small $space-one !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.account-selector {
|
|
|
|
cursor: pointer;
|
|
|
|
padding: $space-small $space-large;
|
|
|
|
|
|
|
|
.ion-ios-checkmark {
|
|
|
|
font-size: $font-size-big;
|
|
|
|
|
|
|
|
& + .account--details {
|
|
|
|
padding-left: $space-normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.account--details {
|
|
|
|
padding-left: $space-large + $space-smaller;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-bottom: $space-large;
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
.account--name {
|
|
|
|
cursor: pointer;
|
|
|
|
font-size: $font-size-medium;
|
|
|
|
font-weight: $font-weight-medium;
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.account--role {
|
|
|
|
cursor: pointer;
|
|
|
|
font-size: $font-size-mini;
|
|
|
|
text-transform: capitalize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|