Chatwoot/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue

128 lines
2.8 KiB
Vue
Raw Normal View History

<template>
<div class="conv-header">
<div class="user">
<Thumbnail
:src="chat.meta.sender.thumbnail"
size="40px"
:badge="chat.meta.sender.channel"
:username="chat.meta.sender.name"
/>
2019-11-14 08:16:43 +00:00
<div class="user--profile__meta">
<h3 v-if="!isContactPanelOpen" class="user--name text-truncate">
2019-11-14 08:16:43 +00:00
{{ chat.meta.sender.name }}
</h3>
<button
2020-03-22 06:14:40 +00:00
class="user--profile__button clear button small"
2019-11-14 08:16:43 +00:00
@click="$emit('contactPanelToggle')"
>
{{ viewProfileButtonLabel }}
</button>
</div>
</div>
<div class="flex-container">
<div class="multiselect-box ion-headphone">
<multiselect
v-model="currentChat.meta.assignee"
:options="agentList"
label="name"
:allow-empty="true"
deselect-label="Remove"
placeholder="Select Agent"
selected-label=""
select-label="Assign"
track-by="id"
@select="assignAgent"
@remove="removeAgent"
>
<span slot="noResult">{{ $t('AGENT_MGMT.SEARCH.NO_RESULTS') }}</span>
</multiselect>
</div>
<ResolveButton />
</div>
</div>
</template>
<script>
/* eslint no-console: 0 */
/* eslint no-param-reassign: 0 */
/* eslint no-shadow: 0 */
/* global bus */
import { mapGetters } from 'vuex';
import Thumbnail from '../Thumbnail';
import ResolveButton from '../../buttons/ResolveButton';
export default {
components: {
Thumbnail,
ResolveButton,
},
2019-11-14 08:16:43 +00:00
props: {
chat: {
type: Object,
default: () => {},
},
isContactPanelOpen: {
type: Boolean,
default: false,
},
},
data() {
return {
currentChatAssignee: null,
};
},
computed: {
...mapGetters({
agents: 'agents/getVerifiedAgents',
currentChat: 'getSelectedChat',
}),
agentList() {
return [
{
confirmed: true,
name: 'None',
id: 0,
role: 'agent',
account_id: 0,
email: 'None',
},
...this.agents,
];
},
2019-11-14 08:16:43 +00:00
viewProfileButtonLabel() {
return `${
this.isContactPanelOpen
? this.$t('CONVERSATION.HEADER.CLOSE')
: this.$t('CONVERSATION.HEADER.OPEN')
} ${this.$t('CONVERSATION.HEADER.DETAILS')}`;
2019-11-14 08:16:43 +00:00
},
},
methods: {
assignAgent(agent) {
this.$store
.dispatch('assignAgent', {
conversationId: this.currentChat.id,
agentId: agent.id,
})
.then(() => {
bus.$emit('newToastMessage', this.$t('CONVERSATION.CHANGE_AGENT'));
});
},
2019-11-14 08:16:43 +00:00
removeAgent() {},
},
};
</script>
<style lang="scss" scoped>
.text-truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>