2021-11-18 13:45:02 +00:00
|
|
|
l<template>
|
2021-03-02 17:14:04 +00:00
|
|
|
<div class="conversations-list-wrap">
|
2020-11-07 20:16:45 +00:00
|
|
|
<slot></slot>
|
2021-11-18 13:45:02 +00:00
|
|
|
<div class="chat-list__top" :class="{ filter__applied: hasAppliedFilters }">
|
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>
|
2021-11-18 13:45:02 +00:00
|
|
|
|
|
|
|
<div class="filter--actions">
|
|
|
|
<chat-filter
|
|
|
|
v-if="!hasAppliedFilters"
|
|
|
|
@statusFilterChange="updateStatusType"
|
|
|
|
/>
|
|
|
|
<woot-button
|
|
|
|
v-else
|
|
|
|
variant="clear"
|
|
|
|
color-scheme="danger"
|
|
|
|
class="btn-clear-filters"
|
|
|
|
@click="resetAndFetchData"
|
|
|
|
>
|
|
|
|
{{ $t('FILTER.CLEAR_BUTTON_LABEL') }}
|
|
|
|
</woot-button>
|
|
|
|
<woot-button
|
|
|
|
v-tooltip.top-end="$t('FILTER.TOOLTIP_LABEL')"
|
|
|
|
variant="clear"
|
|
|
|
color-scheme="secondary"
|
|
|
|
class="btn-filter"
|
|
|
|
@click="onToggleAdvanceFiltersModal"
|
|
|
|
>
|
|
|
|
<i class="icon ion-ios-settings-strong" />
|
|
|
|
</woot-button>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
|
2019-09-02 14:56:28 +00:00
|
|
|
<chat-type-tabs
|
2021-11-18 13:45:02 +00:00
|
|
|
v-if="!hasAppliedFilters"
|
2019-09-02 14:56:28 +00:00
|
|
|
: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>
|
|
|
|
|
2021-08-09 07:38:52 +00:00
|
|
|
<div ref="activeConversation" 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"
|
2021-09-29 10:53:39 +00:00
|
|
|
:show-assignee="showAssigneeInConversationCard"
|
2019-09-02 14:56:28 +00:00
|
|
|
/>
|
2020-02-26 15:45:01 +00:00
|
|
|
|
|
|
|
<div v-if="chatListLoading" class="text-center">
|
|
|
|
<span class="spinner"></span>
|
|
|
|
</div>
|
|
|
|
|
2021-05-20 08:21:46 +00:00
|
|
|
<woot-button
|
2020-02-26 15:45:01 +00:00
|
|
|
v-if="!hasCurrentPageEndReached && !chatListLoading"
|
2021-05-20 08:21:46 +00:00
|
|
|
variant="clear"
|
|
|
|
size="expanded"
|
2021-11-18 13:45:02 +00:00
|
|
|
@click="loadMoreConversations"
|
2020-02-26 15:45:01 +00:00
|
|
|
>
|
|
|
|
{{ $t('CHAT_LIST.LOAD_MORE_CONVERSATIONS') }}
|
2021-05-20 08:21:46 +00:00
|
|
|
</woot-button>
|
2020-02-26 15:45:01 +00:00
|
|
|
|
|
|
|
<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>
|
2021-11-18 13:45:02 +00:00
|
|
|
<woot-modal
|
|
|
|
:show.sync="showAdvancedFilters"
|
|
|
|
:on-close="onToggleAdvanceFiltersModal"
|
|
|
|
>
|
|
|
|
<conversation-advanced-filter
|
|
|
|
v-if="showAdvancedFilters"
|
|
|
|
:filter-types="advancedFilterTypes"
|
|
|
|
:on-close="onToggleAdvanceFiltersModal"
|
|
|
|
@applyFilter="onApplyFilter"
|
|
|
|
/>
|
|
|
|
</woot-modal>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
|
|
|
import ChatFilter from './widgets/conversation/ChatFilter';
|
2021-11-18 13:45:02 +00:00
|
|
|
import ConversationAdvancedFilter from './widgets/conversation/ConversationAdvancedFilter';
|
2019-08-14 09:48:44 +00:00
|
|
|
import ChatTypeTabs from './widgets/ChatTypeTabs';
|
|
|
|
import ConversationCard from './widgets/conversation/ConversationCard';
|
|
|
|
import timeMixin from '../mixins/time';
|
2021-08-09 07:38:52 +00:00
|
|
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
2019-08-14 09:48:44 +00:00
|
|
|
import conversationMixin from '../mixins/conversations';
|
|
|
|
import wootConstants from '../constants';
|
2021-11-18 13:45:02 +00:00
|
|
|
import advancedFilterTypes from './widgets/conversation/advancedFilterItems';
|
|
|
|
import filterQueryGenerator from '../helper/filterQueryGenerator.js';
|
|
|
|
|
2021-08-09 07:38:52 +00:00
|
|
|
import {
|
|
|
|
hasPressedAltAndJKey,
|
|
|
|
hasPressedAltAndKKey,
|
|
|
|
} from 'shared/helpers/KeyboardHelpers';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2019-12-28 16:26:42 +00:00
|
|
|
components: {
|
|
|
|
ChatTypeTabs,
|
|
|
|
ConversationCard,
|
|
|
|
ChatFilter,
|
2021-11-18 13:45:02 +00:00
|
|
|
ConversationAdvancedFilter,
|
2019-12-28 16:26:42 +00:00
|
|
|
},
|
2021-08-09 07:38:52 +00:00
|
|
|
mixins: [timeMixin, conversationMixin, eventListenerMixins],
|
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,
|
2021-11-18 13:45:02 +00:00
|
|
|
showAdvancedFilters: false,
|
|
|
|
advancedFilterTypes: advancedFilterTypes.map(filter => ({
|
|
|
|
...filter,
|
|
|
|
attributeName: this.$t(`FILTER.ATTRIBUTES.${filter.attributeI18nKey}`),
|
|
|
|
})),
|
2019-12-01 04:46:51 +00:00
|
|
|
};
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2021-08-09 07:38:52 +00:00
|
|
|
currentChat: 'getSelectedChat',
|
2019-08-14 09:48:44 +00:00
|
|
|
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',
|
2021-11-18 13:45:02 +00:00
|
|
|
appliedFilters: 'getAppliedFilters',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
2021-11-18 13:45:02 +00:00
|
|
|
hasAppliedFilters() {
|
|
|
|
return this.appliedFilters.length;
|
|
|
|
},
|
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
|
|
|
},
|
2021-09-29 10:53:39 +00:00
|
|
|
showAssigneeInConversationCard() {
|
|
|
|
return this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE.ALL;
|
|
|
|
},
|
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
|
|
|
|
);
|
|
|
|
},
|
2021-11-18 13:45:02 +00:00
|
|
|
currentPageFilterKey() {
|
|
|
|
return this.hasAppliedFilters ? 'appliedFilters' : this.activeAssigneeTab;
|
|
|
|
},
|
|
|
|
currentFiltersPage() {
|
|
|
|
return this.$store.getters['conversationPage/getCurrentPageFilter'](
|
|
|
|
this.currentPageFilterKey
|
|
|
|
);
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
hasCurrentPageEndReached() {
|
|
|
|
return this.$store.getters['conversationPage/getHasEndReached'](
|
2021-11-18 13:45:02 +00:00
|
|
|
this.currentPageFilterKey
|
2020-02-26 15:45:01 +00:00
|
|
|
);
|
|
|
|
},
|
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-11-18 13:45:02 +00:00
|
|
|
if (!this.hasAppliedFilters) {
|
|
|
|
const filters = this.conversationFilters;
|
|
|
|
if (this.activeAssigneeTab === 'me') {
|
|
|
|
conversationList = [...this.mineChatsList(filters)];
|
|
|
|
} else if (this.activeAssigneeTab === 'unassigned') {
|
|
|
|
conversationList = [...this.unAssignedChatsList(filters)];
|
|
|
|
} else {
|
|
|
|
conversationList = [...this.allChatList(filters)];
|
|
|
|
}
|
2020-06-25 15:34:03 +00:00
|
|
|
} else {
|
2021-11-18 13:45:02 +00:00
|
|
|
conversationList = [...this.chatLists];
|
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: {
|
2021-11-18 13:45:02 +00:00
|
|
|
onApplyFilter(payload) {
|
|
|
|
if (this.$route.name !== 'home') {
|
|
|
|
this.$router.push({ name: 'home' });
|
|
|
|
}
|
|
|
|
this.$store.dispatch('conversationPage/reset');
|
|
|
|
this.$store.dispatch('emptyAllConversations');
|
|
|
|
this.fetchFilteredConversations(payload);
|
|
|
|
},
|
|
|
|
onToggleAdvanceFiltersModal() {
|
|
|
|
this.showAdvancedFilters = !this.showAdvancedFilters;
|
|
|
|
},
|
2021-09-15 14:45:06 +00:00
|
|
|
getKeyboardListenerParams() {
|
2021-08-09 07:38:52 +00:00
|
|
|
const allConversations = this.$refs.activeConversation.querySelectorAll(
|
|
|
|
'div.conversations-list div.conversation'
|
|
|
|
);
|
|
|
|
const activeConversation = this.$refs.activeConversation.querySelector(
|
|
|
|
'div.conversations-list div.conversation.active'
|
|
|
|
);
|
|
|
|
const activeConversationIndex = [...allConversations].indexOf(
|
|
|
|
activeConversation
|
|
|
|
);
|
|
|
|
const lastConversationIndex = allConversations.length - 1;
|
2021-09-15 14:45:06 +00:00
|
|
|
return {
|
|
|
|
allConversations,
|
|
|
|
activeConversation,
|
|
|
|
activeConversationIndex,
|
|
|
|
lastConversationIndex,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
handleKeyEvents(e) {
|
2021-08-09 07:38:52 +00:00
|
|
|
if (hasPressedAltAndJKey(e)) {
|
2021-09-15 14:45:06 +00:00
|
|
|
const {
|
|
|
|
allConversations,
|
|
|
|
activeConversationIndex,
|
|
|
|
} = this.getKeyboardListenerParams();
|
2021-08-09 07:38:52 +00:00
|
|
|
if (activeConversationIndex === -1) {
|
|
|
|
allConversations[0].click();
|
|
|
|
}
|
|
|
|
if (activeConversationIndex >= 1) {
|
|
|
|
allConversations[activeConversationIndex - 1].click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasPressedAltAndKKey(e)) {
|
2021-09-15 14:45:06 +00:00
|
|
|
const {
|
|
|
|
allConversations,
|
|
|
|
activeConversationIndex,
|
|
|
|
lastConversationIndex,
|
|
|
|
} = this.getKeyboardListenerParams();
|
2021-08-09 07:38:52 +00:00
|
|
|
if (activeConversationIndex === -1) {
|
|
|
|
allConversations[lastConversationIndex].click();
|
|
|
|
} else if (activeConversationIndex < lastConversationIndex) {
|
|
|
|
allConversations[activeConversationIndex + 1].click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
resetAndFetchData() {
|
|
|
|
this.$store.dispatch('conversationPage/reset');
|
|
|
|
this.$store.dispatch('emptyAllConversations');
|
2021-11-18 13:45:02 +00:00
|
|
|
this.$store.dispatch('clearConversationFilters');
|
2020-02-26 15:45:01 +00:00
|
|
|
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
|
|
|
},
|
2021-11-18 13:45:02 +00:00
|
|
|
loadMoreConversations() {
|
|
|
|
if (!this.hasAppliedFilters) {
|
|
|
|
this.fetchConversations();
|
|
|
|
} else {
|
|
|
|
this.fetchFilteredConversations(this.appliedFilters);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fetchFilteredConversations(payload) {
|
|
|
|
let page = this.currentFiltersPage + 1;
|
|
|
|
this.$store
|
|
|
|
.dispatch('fetchFilteredConversations', {
|
|
|
|
queryData: filterQueryGenerator(payload),
|
|
|
|
page,
|
|
|
|
})
|
|
|
|
.then(() => this.$emit('conversation-load'));
|
|
|
|
this.showAdvancedFilters = false;
|
|
|
|
},
|
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-05-20 08:21:46 +00:00
|
|
|
@import '~dashboard/assets/scss/woot';
|
2021-11-18 13:45:02 +00:00
|
|
|
|
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
|
|
|
}
|
2021-11-18 13:45:02 +00:00
|
|
|
.filter--actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
.btn-filter {
|
|
|
|
cursor: pointer;
|
|
|
|
i {
|
|
|
|
font-size: var(--font-size-two);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.btn-clear-filters {
|
|
|
|
color: var(--r-500);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.filter__applied {
|
|
|
|
padding: var(--space-slab) 0 !important;
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
</style>
|