2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="conversations-sidebar medium-4 columns">
|
|
|
|
<!-- <SearchBox></SearchBox> -->
|
|
|
|
|
|
|
|
<div class="chat-list__top">
|
2019-09-02 14:56:28 +00:00
|
|
|
<h1 class="page-title">
|
|
|
|
{{ getInboxName }}
|
|
|
|
</h1>
|
2019-08-14 09:48:44 +00:00
|
|
|
<chat-filter @statusFilterChange="getDataForStatusTab"></chat-filter>
|
|
|
|
</div>
|
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<chat-type-tabs
|
|
|
|
:items="assigneeTabItems"
|
|
|
|
:active-tab-index="activeAssigneeTab"
|
|
|
|
class="tab--chat-type"
|
|
|
|
@chatTabChange="getDataForTab"
|
|
|
|
></chat-type-tabs>
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<p
|
|
|
|
v-if="!chatListLoading && !getChatsForTab(activeStatusTab).length"
|
|
|
|
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
|
|
|
|
v-for="chat in getChatsForTab(activeStatusTab)"
|
|
|
|
: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 {
|
|
|
|
mixins: [timeMixin, conversationMixin],
|
2019-09-02 14:56:28 +00:00
|
|
|
props: ['conversationInbox', 'pageTitle'],
|
2019-08-14 09:48:44 +00:00
|
|
|
data: () => ({
|
|
|
|
chats: null,
|
|
|
|
activeStatusTab: 0,
|
|
|
|
activeAssigneeTab: 0,
|
|
|
|
toggleType: true,
|
|
|
|
allMessageType: 2,
|
|
|
|
}),
|
|
|
|
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('fetchAgents');
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
chatLists: 'getAllConversations',
|
|
|
|
mineChatsList: 'getMineChats',
|
|
|
|
allChatList: 'getAllStatusChats',
|
|
|
|
unAssignedChatsList: 'getUnAssignedChats',
|
|
|
|
inboxesList: 'getInboxesList',
|
|
|
|
chatListLoading: 'getChatListLoadingStatus',
|
|
|
|
currentUserID: 'getCurrentUserID',
|
|
|
|
activeInbox: 'getSelectedInbox',
|
|
|
|
}),
|
|
|
|
convStats() {
|
|
|
|
const mineCount = this.mineChatsList.length;
|
|
|
|
const unAssignedCount = this.unAssignedChatsList.length;
|
|
|
|
const allCount = this.allChatList.length;
|
|
|
|
return {
|
|
|
|
mineCount,
|
|
|
|
unAssignedCount,
|
|
|
|
allCount,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
assigneeTabItems() {
|
|
|
|
return this.$t('CHAT_LIST.ASSIGNEE_TYPE_TABS').map((item, index) => ({
|
|
|
|
id: index,
|
|
|
|
name: item.NAME,
|
|
|
|
count: this.convStats[item.KEY] || 0,
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
getInboxName() {
|
|
|
|
const inboxId = Number(this.activeInbox);
|
2019-09-02 14:56:28 +00:00
|
|
|
const [stateInbox] = this.inboxesList.filter(
|
|
|
|
inbox => inbox.channel_id === inboxId
|
|
|
|
);
|
2019-08-14 09:48:44 +00:00
|
|
|
return !stateInbox ? this.pageTitle : stateInbox.label;
|
|
|
|
},
|
|
|
|
getToggleStatus() {
|
|
|
|
if (this.toggleType) {
|
|
|
|
return 'Open';
|
|
|
|
}
|
|
|
|
return 'Resolved';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetchData() {
|
|
|
|
if (this.chatLists.length === 0) {
|
|
|
|
this.$store.dispatch('fetchAllConversations', {
|
2019-10-29 07:20:54 +00:00
|
|
|
inboxId: this.conversationInbox ? this.conversationInbox : undefined,
|
2019-08-14 09:48:44 +00:00
|
|
|
assigneeStatus: this.allMessageType,
|
|
|
|
convStatus: this.activeStatusTab,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getDataForTab(index) {
|
|
|
|
this.activeAssigneeTab = index;
|
|
|
|
if (!(index in this.chatLists)) {
|
|
|
|
// this.$store.dispatch('fetchList', {
|
|
|
|
// inbox: this.conversationInbox,
|
|
|
|
// type: index,
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getDataForStatusTab(index) {
|
|
|
|
this.activeStatusTab = index;
|
|
|
|
},
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
const sorted = copyList.sort((a, b) =>
|
2019-09-02 14:56:28 +00:00
|
|
|
this.wootTime(this.lastMessage(a).created_at).isBefore(
|
|
|
|
this.wootTime(this.lastMessage(b).created_at)
|
|
|
|
)
|
2019-08-14 09:48:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return sorted;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
ChatTypeTabs,
|
|
|
|
ConversationCard,
|
|
|
|
ChatFilter,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</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>
|