2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="conversations-sidebar medium-4 columns">
|
2020-11-07 20:16:45 +00:00
|
|
|
<slot></slot>
|
2019-08-14 09:48:44 +00:00
|
|
|
<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 />
|
2020-06-25 15:34:03 +00:00
|
|
|
{{ pageTitle }}
|
2019-09-02 14:56:28 +00:00
|
|
|
</h1>
|
2020-02-26 15:45:01 +00:00
|
|
|
<chat-filter @statusFilterChange="updateStatusType" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<chat-type-tabs
|
|
|
|
:items="assigneeTabItems"
|
2020-02-26 15:45:01 +00:00
|
|
|
:active-tab="activeAssigneeTab"
|
2019-09-02 14:56:28 +00:00
|
|
|
class="tab--chat-type"
|
2020-02-26 15:45:01 +00:00
|
|
|
@chatTabChange="updateAssigneeTab"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-12-21 17:24:35 +00:00
|
|
|
|
2020-06-25 15:34:03 +00:00
|
|
|
<p v-if="!chatListLoading && !conversationList.length" class="content-box">
|
2019-08-14 09:48:44 +00:00
|
|
|
{{ $t('CHAT_LIST.LIST.404') }}
|
|
|
|
</p>
|
|
|
|
|
2020-02-26 15:45:01 +00:00
|
|
|
<div class="conversations-list">
|
2019-09-02 14:56:28 +00:00
|
|
|
<conversation-card
|
2020-06-25 15:34:03 +00:00
|
|
|
v-for="chat in conversationList"
|
2019-09-02 14:56:28 +00:00
|
|
|
:key="chat.id"
|
2020-06-25 15:34:03 +00:00
|
|
|
:active-label="label"
|
2019-09-02 14:56:28 +00:00
|
|
|
:chat="chat"
|
|
|
|
/>
|
2020-02-26 15:45:01 +00:00
|
|
|
|
|
|
|
<div v-if="chatListLoading" class="text-center">
|
|
|
|
<span class="spinner"></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="!hasCurrentPageEndReached && !chatListLoading"
|
2020-03-22 06:14:40 +00:00
|
|
|
class="clear button load-more-conversations"
|
2020-02-26 15:45:01 +00:00
|
|
|
@click="fetchConversations"
|
|
|
|
>
|
|
|
|
{{ $t('CHAT_LIST.LOAD_MORE_CONVERSATIONS') }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p
|
|
|
|
v-if="
|
2020-06-25 15:34:03 +00:00
|
|
|
conversationList.length &&
|
2020-02-26 15:45:01 +00:00
|
|
|
hasCurrentPageEndReached &&
|
|
|
|
!chatListLoading
|
|
|
|
"
|
|
|
|
class="text-center text-muted end-of-list-text"
|
|
|
|
>
|
|
|
|
{{ $t('CHAT_LIST.EOF') }}
|
|
|
|
</p>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
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],
|
2020-06-25 15:34:03 +00:00
|
|
|
props: {
|
|
|
|
conversationInbox: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
2019-12-01 04:46:51 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-02-26 15:45:01 +00:00
|
|
|
activeAssigneeTab: wootConstants.ASSIGNEE_TYPE.ME,
|
|
|
|
activeStatus: wootConstants.STATUS_TYPE.OPEN,
|
2019-12-01 04:46:51 +00:00
|
|
|
};
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
chatLists: 'getAllConversations',
|
|
|
|
mineChatsList: 'getMineChats',
|
|
|
|
allChatList: 'getAllStatusChats',
|
|
|
|
unAssignedChatsList: 'getUnAssignedChats',
|
|
|
|
chatListLoading: 'getChatListLoadingStatus',
|
|
|
|
currentUserID: 'getCurrentUserID',
|
|
|
|
activeInbox: 'getSelectedInbox',
|
2020-06-14 08:37:52 +00:00
|
|
|
conversationStats: 'conversationStats/getStats',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
|
|
|
assigneeTabItems() {
|
2020-06-14 08:37:52 +00:00
|
|
|
return this.$t('CHAT_LIST.ASSIGNEE_TYPE_TABS').map(item => {
|
|
|
|
const count = this.conversationStats[item.COUNT_KEY] || 0;
|
|
|
|
return {
|
|
|
|
key: item.KEY,
|
|
|
|
name: item.NAME,
|
|
|
|
count,
|
|
|
|
};
|
|
|
|
});
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
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
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
currentPage() {
|
|
|
|
return this.$store.getters['conversationPage/getCurrentPage'](
|
|
|
|
this.activeAssigneeTab
|
|
|
|
);
|
|
|
|
},
|
|
|
|
hasCurrentPageEndReached() {
|
|
|
|
return this.$store.getters['conversationPage/getHasEndReached'](
|
|
|
|
this.activeAssigneeTab
|
|
|
|
);
|
|
|
|
},
|
2020-06-09 10:56:33 +00:00
|
|
|
conversationFilters() {
|
|
|
|
return {
|
|
|
|
inboxId: this.conversationInbox ? this.conversationInbox : undefined,
|
|
|
|
assigneeType: this.activeAssigneeTab,
|
|
|
|
status: this.activeStatus,
|
|
|
|
page: this.currentPage + 1,
|
2020-06-25 15:34:03 +00:00
|
|
|
labels: this.label ? [this.label] : undefined,
|
2020-06-09 10:56:33 +00:00
|
|
|
};
|
|
|
|
},
|
2020-06-25 15:34:03 +00:00
|
|
|
pageTitle() {
|
|
|
|
if (this.inbox.name) {
|
|
|
|
return this.inbox.name;
|
|
|
|
}
|
|
|
|
if (this.label) {
|
|
|
|
return `#${this.label}`;
|
|
|
|
}
|
|
|
|
return this.$t('CHAT_LIST.TAB_HEADING');
|
|
|
|
},
|
|
|
|
conversationList() {
|
|
|
|
let conversationList = [];
|
|
|
|
if (this.activeAssigneeTab === 'me') {
|
|
|
|
conversationList = this.mineChatsList.slice();
|
|
|
|
} else if (this.activeAssigneeTab === 'unassigned') {
|
|
|
|
conversationList = this.unAssignedChatsList.slice();
|
|
|
|
} else {
|
|
|
|
conversationList = this.allChatList.slice();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.label) {
|
|
|
|
return conversationList;
|
|
|
|
}
|
|
|
|
|
|
|
|
return conversationList.filter(conversation => {
|
|
|
|
const labels = this.$store.getters[
|
|
|
|
'conversationLabels/getConversationLabels'
|
|
|
|
](conversation.id);
|
|
|
|
return labels.includes(this.label);
|
|
|
|
});
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
conversationInbox() {
|
|
|
|
this.resetAndFetchData();
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-06-25 15:34:03 +00:00
|
|
|
label() {
|
|
|
|
this.resetAndFetchData();
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-12-28 16:26:42 +00:00
|
|
|
mounted() {
|
2020-02-26 15:45:01 +00:00
|
|
|
this.$store.dispatch('setChatFilter', this.activeStatus);
|
|
|
|
this.resetAndFetchData();
|
2020-06-09 10:56:33 +00:00
|
|
|
|
|
|
|
bus.$on('fetch_conversation_stats', () => {
|
2020-06-14 08:37:52 +00:00
|
|
|
this.$store.dispatch('conversationStats/get', this.conversationFilters);
|
2020-06-09 10:56:33 +00:00
|
|
|
});
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2020-02-26 15:45:01 +00:00
|
|
|
resetAndFetchData() {
|
|
|
|
this.$store.dispatch('conversationPage/reset');
|
|
|
|
this.$store.dispatch('emptyAllConversations');
|
|
|
|
this.fetchConversations();
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-12-01 04:46:51 +00:00
|
|
|
fetchConversations() {
|
2020-06-09 10:56:33 +00:00
|
|
|
this.$store.dispatch('fetchAllConversations', this.conversationFilters);
|
2019-12-01 04:46:51 +00:00
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
updateAssigneeTab(selectedTab) {
|
|
|
|
if (this.activeAssigneeTab !== selectedTab) {
|
|
|
|
this.activeAssigneeTab = selectedTab;
|
|
|
|
if (!this.currentPage) {
|
|
|
|
this.fetchConversations();
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
updateStatusType(index) {
|
2019-12-01 04:46:51 +00:00
|
|
|
if (this.activeStatus !== index) {
|
|
|
|
this.activeStatus = index;
|
2020-02-26 15:45:01 +00:00
|
|
|
this.resetAndFetchData();
|
2019-12-01 04:46:51 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</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>
|