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
|
|
|
|
v-if="!isCards && !isOptions && !isForm && !isArticle"
|
|
|
|
class="chat-bubble agent"
|
|
|
|
>
|
2020-08-11 04:27:42 +00:00
|
|
|
<span v-html="formatMessage(message, false)"></span>
|
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"
|
|
|
|
>
|
|
|
|
</chat-options>
|
|
|
|
</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"
|
|
|
|
>
|
|
|
|
</chat-form>
|
|
|
|
<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"
|
|
|
|
>
|
|
|
|
</chat-card>
|
|
|
|
</div>
|
|
|
|
<div v-if="isArticle">
|
|
|
|
<chat-article :items="messageContentAttributes.items"></chat-article>
|
|
|
|
</div>
|
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';
|
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,
|
|
|
|
},
|
2019-11-23 18:59:55 +00:00
|
|
|
mixins: [messageFormatterMixin],
|
2019-10-29 07:20:54 +00:00
|
|
|
props: {
|
|
|
|
message: String,
|
2020-01-09 07:36:40 +00:00
|
|
|
contentType: String,
|
|
|
|
messageType: Number,
|
|
|
|
messageId: Number,
|
|
|
|
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';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
|
|
|
|
.chat-bubble {
|
|
|
|
&.agent {
|
|
|
|
background: $color-white;
|
|
|
|
border-bottom-left-radius: $space-smaller;
|
|
|
|
color: $color-body;
|
2020-05-02 04:17:36 +00:00
|
|
|
|
|
|
|
.link {
|
|
|
|
word-break: break-word;
|
|
|
|
color: $color-woot;
|
|
|
|
}
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|