2019-10-29 07:20:54 +00:00
|
|
|
<template>
|
2020-07-07 18:34:44 +00:00
|
|
|
<div class="chat-bubble-wrap">
|
2020-04-10 11:12:37 +00:00
|
|
|
<div
|
2021-06-22 07:31:19 +00:00
|
|
|
v-if="
|
|
|
|
!isCards && !isOptions && !isForm && !isArticle && !isCards && !isCSAT
|
|
|
|
"
|
2020-04-10 11:12:37 +00:00
|
|
|
class="chat-bubble agent"
|
2022-04-01 15:29:03 +00:00
|
|
|
:class="$dm('bg-white', 'dark:bg-slate-700')"
|
2020-04-10 11:12:37 +00:00
|
|
|
>
|
2022-04-01 15:29:03 +00:00
|
|
|
<div
|
2022-04-21 05:57:28 +00:00
|
|
|
v-dompurify-html="formatMessage(message, false)"
|
2022-04-01 15:29:03 +00:00
|
|
|
class="message-content"
|
|
|
|
:class="$dm('text-black-900', 'dark:text-slate-50')"
|
2022-06-10 13:59:52 +00:00
|
|
|
/>
|
2020-04-10 11:12:37 +00:00
|
|
|
<email-input
|
|
|
|
v-if="isTemplateEmail"
|
|
|
|
:message-id="messageId"
|
|
|
|
:message-content-attributes="messageContentAttributes"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="isOptions">
|
|
|
|
<chat-options
|
|
|
|
:title="message"
|
|
|
|
:options="messageContentAttributes.items"
|
|
|
|
:hide-fields="!!messageContentAttributes.submitted_values"
|
|
|
|
@click="onOptionSelect"
|
2022-06-10 13:59:52 +00:00
|
|
|
/>
|
2020-04-10 11:12:37 +00:00
|
|
|
</div>
|
|
|
|
<chat-form
|
2020-05-17 17:19:45 +00:00
|
|
|
v-if="isForm && !messageContentAttributes.submitted_values"
|
2020-04-10 11:12:37 +00:00
|
|
|
:items="messageContentAttributes.items"
|
2020-07-08 07:43:48 +00:00
|
|
|
:button-label="messageContentAttributes.button_label"
|
2020-04-10 11:12:37 +00:00
|
|
|
:submitted-values="messageContentAttributes.submitted_values"
|
|
|
|
@submit="onFormSubmit"
|
2022-06-10 13:59:52 +00:00
|
|
|
/>
|
2020-04-10 11:12:37 +00:00
|
|
|
<div v-if="isCards">
|
|
|
|
<chat-card
|
|
|
|
v-for="item in messageContentAttributes.items"
|
|
|
|
:key="item.title"
|
|
|
|
:media-url="item.media_url"
|
|
|
|
:title="item.title"
|
|
|
|
:description="item.description"
|
|
|
|
:actions="item.actions"
|
2022-06-10 13:59:52 +00:00
|
|
|
/>
|
2020-04-10 11:12:37 +00:00
|
|
|
</div>
|
|
|
|
<div v-if="isArticle">
|
2022-06-10 13:59:52 +00:00
|
|
|
<chat-article :items="messageContentAttributes.items" />
|
2020-04-10 11:12:37 +00:00
|
|
|
</div>
|
2021-06-25 06:30:49 +00:00
|
|
|
<customer-satisfaction
|
|
|
|
v-if="isCSAT"
|
|
|
|
:message-content-attributes="messageContentAttributes.submitted_values"
|
2021-07-07 05:54:08 +00:00
|
|
|
:message-id="messageId"
|
2021-06-25 06:30:49 +00:00
|
|
|
/>
|
2020-01-09 07:36:40 +00:00
|
|
|
</div>
|
2019-10-29 07:20:54 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-23 18:59:55 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2020-04-10 11:12:37 +00:00
|
|
|
import ChatCard from 'shared/components/ChatCard';
|
|
|
|
import ChatForm from 'shared/components/ChatForm';
|
|
|
|
import ChatOptions from 'shared/components/ChatOptions';
|
|
|
|
import ChatArticle from './template/Article';
|
2020-01-09 07:36:40 +00:00
|
|
|
import EmailInput from './template/EmailInput';
|
2021-06-22 07:31:19 +00:00
|
|
|
import CustomerSatisfaction from 'shared/components/CustomerSatisfaction';
|
2022-04-01 15:29:03 +00:00
|
|
|
import darkModeMixin from 'widget/mixins/darkModeMixin.js';
|
2019-11-23 18:59:55 +00:00
|
|
|
|
2019-10-29 07:20:54 +00:00
|
|
|
export default {
|
|
|
|
name: 'AgentMessageBubble',
|
2020-01-09 07:36:40 +00:00
|
|
|
components: {
|
2020-04-10 11:12:37 +00:00
|
|
|
ChatArticle,
|
|
|
|
ChatCard,
|
|
|
|
ChatForm,
|
|
|
|
ChatOptions,
|
2020-01-09 07:36:40 +00:00
|
|
|
EmailInput,
|
2021-06-22 07:31:19 +00:00
|
|
|
CustomerSatisfaction,
|
2020-01-09 07:36:40 +00:00
|
|
|
},
|
2022-04-01 15:29:03 +00:00
|
|
|
mixins: [messageFormatterMixin, darkModeMixin],
|
2019-10-29 07:20:54 +00:00
|
|
|
props: {
|
2021-06-22 07:31:19 +00:00
|
|
|
message: { type: String, default: null },
|
|
|
|
contentType: { type: String, default: null },
|
|
|
|
messageType: { type: Number, default: null },
|
|
|
|
messageId: { type: Number, default: null },
|
2020-01-09 07:36:40 +00:00
|
|
|
messageContentAttributes: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2020-04-10 11:12:37 +00:00
|
|
|
isTemplate() {
|
|
|
|
return this.messageType === 3;
|
|
|
|
},
|
|
|
|
isTemplateEmail() {
|
|
|
|
return this.contentType === 'input_email';
|
|
|
|
},
|
|
|
|
isCards() {
|
|
|
|
return this.contentType === 'cards';
|
|
|
|
},
|
|
|
|
isOptions() {
|
|
|
|
return this.contentType === 'input_select';
|
|
|
|
},
|
|
|
|
isForm() {
|
|
|
|
return this.contentType === 'form';
|
|
|
|
},
|
|
|
|
isArticle() {
|
|
|
|
return this.contentType === 'article';
|
|
|
|
},
|
2021-06-22 07:31:19 +00:00
|
|
|
isCSAT() {
|
|
|
|
return this.contentType === 'input_csat';
|
|
|
|
},
|
2020-04-10 11:12:37 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onResponse(messageResponse) {
|
|
|
|
this.$store.dispatch('message/update', messageResponse);
|
|
|
|
},
|
|
|
|
onOptionSelect(selectedOption) {
|
|
|
|
this.onResponse({
|
|
|
|
submittedValues: [selectedOption],
|
|
|
|
messageId: this.messageId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onFormSubmit(formValues) {
|
|
|
|
const formValuesAsArray = Object.keys(formValues).map(key => ({
|
|
|
|
name: key,
|
|
|
|
value: formValues[key],
|
|
|
|
}));
|
|
|
|
this.onResponse({
|
|
|
|
submittedValues: formValuesAsArray,
|
|
|
|
messageId: this.messageId,
|
|
|
|
});
|
2020-01-09 07:36:40 +00:00
|
|
|
},
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2021-01-15 09:10:50 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
|
|
|
|
.chat-bubble .message-content::v-deep pre {
|
|
|
|
background: $color-primary-light;
|
|
|
|
color: $color-body;
|
2022-09-05 07:16:27 +00:00
|
|
|
overflow-y: auto;
|
2021-01-15 09:10:50 +00:00
|
|
|
padding: $space-smaller;
|
|
|
|
}
|
|
|
|
</style>
|