2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="conversations-sidebar medium-4 columns">
|
|
|
|
<div class="chat-list__top">
|
2019-09-02 14:56:28 +00:00
|
|
|
<h1 class="page-title">
|
2019-12-16 12:53:14 +00:00
|
|
|
<woot-sidemenu-icon />
|
2019-12-28 16:26:42 +00:00
|
|
|
{{ inbox.name || pageTitle }}
|
2019-09-02 14:56:28 +00:00
|
|
|
</h1>
|
2019-12-16 12:53:14 +00:00
|
|
|
<chat-filter @statusFilterChange="getDataForStatusTab" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<chat-type-tabs
|
|
|
|
:items="assigneeTabItems"
|
|
|
|
:active-tab-index="activeAssigneeTab"
|
|
|
|
class="tab--chat-type"
|
|
|
|
@chatTabChange="getDataForTab"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-12-21 17:24:35 +00:00
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<p
|
2019-12-01 04:46:51 +00:00
|
|
|
v-if="!chatListLoading && !getChatsForTab(activeStatus).length"
|
2019-09-02 14:56:28 +00:00
|
|
|
class="content-box"
|
|
|
|
>
|
2019-08-14 09:48:44 +00:00
|
|
|
{{ $t('CHAT_LIST.LIST.404') }}
|
|
|
|
</p>
|
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<div v-if="chatListLoading" class="text-center">
|
|
|
|
<span class="spinner message"></span>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<transition-group
|
|
|
|
name="conversations-list"
|
|
|
|
tag="div"
|
|
|
|
class="conversations-list"
|
|
|
|
>
|
|
|
|
<conversation-card
|
2019-12-01 04:46:51 +00:00
|
|
|
v-for="chat in getChatsForTab(activeStatus)"
|
2019-09-02 14:56:28 +00:00
|
|
|
:key="chat.id"
|
|
|
|
:chat="chat"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</transition-group>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
/* eslint-env browser */
|
|
|
|
/* eslint no-console: 0 */
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
import ChatFilter from './widgets/conversation/ChatFilter';
|
|
|
|
import ChatTypeTabs from './widgets/ChatTypeTabs';
|
|
|
|
import ConversationCard from './widgets/conversation/ConversationCard';
|
|
|
|
import timeMixin from '../mixins/time';
|
|
|
|
import conversationMixin from '../mixins/conversations';
|
|
|
|
import wootConstants from '../constants';
|
|
|
|
|
|
|
|
export default {
|
2019-12-28 16:26:42 +00:00
|
|
|
components: {
|
|
|
|
ChatTypeTabs,
|
|
|
|
ConversationCard,
|
|
|
|
ChatFilter,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
mixins: [timeMixin, conversationMixin],
|
2019-09-02 14:56:28 +00:00
|
|
|
props: ['conversationInbox', 'pageTitle'],
|
2019-12-01 04:46:51 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
activeAssigneeTab: 0,
|
|
|
|
activeStatus: 0,
|
|
|
|
};
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
chatLists: 'getAllConversations',
|
|
|
|
mineChatsList: 'getMineChats',
|
|
|
|
allChatList: 'getAllStatusChats',
|
|
|
|
unAssignedChatsList: 'getUnAssignedChats',
|
|
|
|
chatListLoading: 'getChatListLoadingStatus',
|
|
|
|
currentUserID: 'getCurrentUserID',
|
|
|
|
activeInbox: 'getSelectedInbox',
|
2019-12-01 04:46:51 +00:00
|
|
|
convStats: 'getConvTabStats',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
|
|
|
assigneeTabItems() {
|
|
|
|
return this.$t('CHAT_LIST.ASSIGNEE_TYPE_TABS').map((item, index) => ({
|
|
|
|
id: index,
|
|
|
|
name: item.NAME,
|
|
|
|
count: this.convStats[item.KEY] || 0,
|
|
|
|
}));
|
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
inbox() {
|
|
|
|
return this.$store.getters['inboxes/getInbox'](this.activeInbox);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
getToggleStatus() {
|
|
|
|
if (this.toggleType) {
|
|
|
|
return 'Open';
|
|
|
|
}
|
|
|
|
return 'Resolved';
|
|
|
|
},
|
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
mounted() {
|
|
|
|
this.$watch('$store.state.route', () => {
|
|
|
|
if (this.$store.state.route.name !== 'inbox_conversation') {
|
|
|
|
this.$store.dispatch('emptyAllConversations');
|
|
|
|
this.fetchData();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$store.dispatch('emptyAllConversations');
|
|
|
|
this.fetchData();
|
|
|
|
this.$store.dispatch('agents/get');
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
|
|
|
fetchData() {
|
|
|
|
if (this.chatLists.length === 0) {
|
2019-12-01 04:46:51 +00:00
|
|
|
this.fetchConversations();
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
2019-12-01 04:46:51 +00:00
|
|
|
fetchConversations() {
|
|
|
|
this.$store.dispatch('fetchAllConversations', {
|
|
|
|
inboxId: this.conversationInbox ? this.conversationInbox : undefined,
|
|
|
|
assigneeType: this.activeAssigneeTab,
|
|
|
|
status: this.activeStatus ? 'resolved' : 'open',
|
|
|
|
});
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
getDataForTab(index) {
|
2019-12-01 04:46:51 +00:00
|
|
|
if (this.activeAssigneeTab !== index) {
|
|
|
|
this.activeAssigneeTab = index;
|
|
|
|
this.fetchConversations();
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getDataForStatusTab(index) {
|
2019-12-01 04:46:51 +00:00
|
|
|
if (this.activeStatus !== index) {
|
|
|
|
this.activeStatus = index;
|
|
|
|
this.fetchConversations();
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
getChatsForTab() {
|
|
|
|
let copyList = [];
|
|
|
|
if (this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.MINE) {
|
|
|
|
copyList = this.mineChatsList.slice();
|
2019-09-02 14:56:28 +00:00
|
|
|
} else if (
|
|
|
|
this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.UNASSIGNED
|
|
|
|
) {
|
2019-08-14 09:48:44 +00:00
|
|
|
copyList = this.unAssignedChatsList.slice();
|
|
|
|
} else {
|
|
|
|
copyList = this.allChatList.slice();
|
|
|
|
}
|
2019-11-21 06:32:10 +00:00
|
|
|
const sorted = copyList.sort(
|
|
|
|
(a, b) =>
|
|
|
|
this.lastMessage(b).created_at - this.lastMessage(a).created_at
|
2019-08-14 09:48:44 +00:00
|
|
|
);
|
|
|
|
return sorted;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-10-16 09:06:17 +00:00
|
|
|
@import '~dashboard/assets/scss/variables';
|
2019-08-14 09:48:44 +00:00
|
|
|
.spinner {
|
|
|
|
margin-top: $space-normal;
|
|
|
|
margin-bottom: $space-normal;
|
|
|
|
}
|
|
|
|
</style>
|