2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-03-02 17:14:04 +00:00
|
|
|
<div class="conversations-list-wrap">
|
2020-11-07 20:16:45 +00:00
|
|
|
<slot></slot>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="chat-list__top">
|
2020-11-25 07:22:39 +00:00
|
|
|
<h1 class="page-title text-truncate" :title="pageTitle">
|
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"
|
2021-03-16 14:14:50 +00:00
|
|
|
:team-id="teamId"
|
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,
|
|
|
|
},
|
2021-03-16 14:14:50 +00:00
|
|
|
teamId: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: 0,
|
|
|
|
},
|
2020-06-25 15:34:03 +00:00
|
|
|
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() {
|
2021-04-22 08:28:04 +00:00
|
|
|
return this.$store.getters['conversationPage/getCurrentPageFilter'](
|
2020-02-26 15:45:01 +00:00
|
|
|
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,
|
2021-03-16 14:14:50 +00:00
|
|
|
teamId: this.teamId ? this.teamId : 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;
|
|
|
|
}
|
2021-02-13 09:28:05 +00:00
|
|
|
if (this.activeTeam.name) {
|
|
|
|
return this.activeTeam.name;
|
|
|
|
}
|
2020-06-25 15:34:03 +00:00
|
|
|
if (this.label) {
|
|
|
|
return `#${this.label}`;
|
|
|
|
}
|
|
|
|
return this.$t('CHAT_LIST.TAB_HEADING');
|
|
|
|
},
|
|
|
|
conversationList() {
|
|
|
|
let conversationList = [];
|
2021-03-20 12:12:29 +00:00
|
|
|
const filters = this.conversationFilters;
|
2020-06-25 15:34:03 +00:00
|
|
|
if (this.activeAssigneeTab === 'me') {
|
2021-03-20 12:12:29 +00:00
|
|
|
conversationList = [...this.mineChatsList(filters)];
|
2020-06-25 15:34:03 +00:00
|
|
|
} else if (this.activeAssigneeTab === 'unassigned') {
|
2021-03-20 12:12:29 +00:00
|
|
|
conversationList = [...this.unAssignedChatsList(filters)];
|
2020-06-25 15:34:03 +00:00
|
|
|
} else {
|
2021-03-20 12:12:29 +00:00
|
|
|
conversationList = [...this.allChatList(filters)];
|
2020-06-25 15:34:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-20 12:12:29 +00:00
|
|
|
return conversationList;
|
2020-06-25 15:34:03 +00:00
|
|
|
},
|
2021-03-16 14:14:50 +00:00
|
|
|
activeTeam() {
|
|
|
|
if (this.teamId) {
|
|
|
|
return this.$store.getters['teams/getTeam'](this.teamId);
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2021-02-13 09:28:05 +00:00
|
|
|
activeTeam() {
|
|
|
|
this.resetAndFetchData();
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
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-11-17 03:45:57 +00:00
|
|
|
this.$store
|
|
|
|
.dispatch('fetchAllConversations', this.conversationFilters)
|
|
|
|
.then(() => this.$emit('conversation-load'));
|
2019-12-01 04:46:51 +00:00
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
updateAssigneeTab(selectedTab) {
|
|
|
|
if (this.activeAssigneeTab !== selectedTab) {
|
2021-04-22 08:28:04 +00:00
|
|
|
bus.$emit('clearSearchInput');
|
2020-02-26 15:45:01 +00:00
|
|
|
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">
|
2021-03-02 17:14:04 +00:00
|
|
|
@import '~dashboard/assets/scss/app.scss';
|
2019-08-14 09:48:44 +00:00
|
|
|
.spinner {
|
2021-03-02 17:14:04 +00:00
|
|
|
margin-top: var(--space-normal);
|
|
|
|
margin-bottom: var(--space-normal);
|
|
|
|
}
|
|
|
|
|
|
|
|
.conversations-list-wrap {
|
|
|
|
flex-shrink: 0;
|
|
|
|
width: 34rem;
|
|
|
|
|
|
|
|
@include breakpoint(large up) {
|
|
|
|
width: 36rem;
|
|
|
|
}
|
|
|
|
@include breakpoint(xlarge up) {
|
2021-03-08 08:00:33 +00:00
|
|
|
width: 35rem;
|
2021-03-02 17:14:04 +00:00
|
|
|
}
|
|
|
|
@include breakpoint(xxlarge up) {
|
2021-03-08 08:00:33 +00:00
|
|
|
width: 38rem;
|
|
|
|
}
|
|
|
|
@include breakpoint(xxxlarge up) {
|
|
|
|
flex-basis: 46rem;
|
2021-03-02 17:14:04 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
</style>
|