2019-10-29 07:20:54 +00:00
|
|
|
<template>
|
2020-05-02 04:17:36 +00:00
|
|
|
<div class="user-message-wrap">
|
|
|
|
<div class="user-message">
|
|
|
|
<div class="message-wrap" :class="{ 'in-progress': isInProgress }">
|
2020-06-15 08:05:52 +00:00
|
|
|
<user-message-bubble
|
2020-05-02 04:17:36 +00:00
|
|
|
v-if="showTextBubble"
|
|
|
|
:message="message.content"
|
|
|
|
:status="message.status"
|
2020-06-15 08:05:52 +00:00
|
|
|
:widget-color="widgetColor"
|
2020-05-02 04:17:36 +00:00
|
|
|
/>
|
2020-06-15 08:05:52 +00:00
|
|
|
<div
|
|
|
|
v-if="hasAttachments"
|
|
|
|
class="chat-bubble has-attachment user"
|
|
|
|
:style="{ backgroundColor: widgetColor }"
|
|
|
|
>
|
2020-05-02 04:17:36 +00:00
|
|
|
<div v-for="attachment in message.attachments" :key="attachment.id">
|
|
|
|
<file-bubble
|
|
|
|
v-if="attachment.file_type !== 'image'"
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:is-in-progress="isInProgress"
|
|
|
|
/>
|
|
|
|
<image-bubble
|
|
|
|
v-else
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:thumb="attachment.thumb_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-04-17 15:45:20 +00:00
|
|
|
</div>
|
2020-03-30 06:45:06 +00:00
|
|
|
</div>
|
2019-10-29 07:20:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-03-30 06:45:06 +00:00
|
|
|
import UserMessageBubble from 'widget/components/UserMessageBubble';
|
|
|
|
import ImageBubble from 'widget/components/ImageBubble';
|
2020-04-02 06:58:38 +00:00
|
|
|
import FileBubble from 'widget/components/FileBubble';
|
2020-03-30 06:45:06 +00:00
|
|
|
import timeMixin from 'dashboard/mixins/time';
|
2021-07-15 08:57:37 +00:00
|
|
|
import messageMixin from '../mixins/messageMixin';
|
2020-06-15 08:05:52 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2019-10-29 07:20:54 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'UserMessage',
|
|
|
|
components: {
|
|
|
|
UserMessageBubble,
|
2020-03-30 06:45:06 +00:00
|
|
|
ImageBubble,
|
2020-04-02 06:58:38 +00:00
|
|
|
FileBubble,
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
2021-07-15 08:57:37 +00:00
|
|
|
mixins: [timeMixin, messageMixin],
|
2019-10-29 07:20:54 +00:00
|
|
|
props: {
|
2020-03-30 06:45:06 +00:00
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2020-06-15 08:05:52 +00:00
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
|
|
|
|
2020-03-30 06:45:06 +00:00
|
|
|
isInProgress() {
|
|
|
|
const { status = '' } = this.message;
|
|
|
|
return status === 'in_progress';
|
|
|
|
},
|
|
|
|
showTextBubble() {
|
|
|
|
const { message } = this;
|
|
|
|
return !!message.content;
|
|
|
|
},
|
|
|
|
readableTime() {
|
|
|
|
const { created_at: createdAt = '' } = this.message;
|
|
|
|
return this.messageStamp(createdAt);
|
2019-11-29 12:12:35 +00:00
|
|
|
},
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
2019-11-27 06:15:33 +00:00
|
|
|
<style lang="scss">
|
2019-10-29 07:20:54 +00:00
|
|
|
@import '~widget/assets/scss/variables.scss';
|
2019-11-27 06:15:33 +00:00
|
|
|
.conversation-wrap {
|
|
|
|
.user-message {
|
|
|
|
align-items: flex-end;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-end;
|
|
|
|
margin: 0 $space-smaller $space-micro auto;
|
|
|
|
max-width: 85%;
|
|
|
|
text-align: right;
|
2019-10-29 07:20:54 +00:00
|
|
|
|
2019-11-27 06:15:33 +00:00
|
|
|
.message-wrap {
|
|
|
|
margin-right: $space-small;
|
2021-01-15 09:10:50 +00:00
|
|
|
max-width: 100%;
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
2020-03-30 06:45:06 +00:00
|
|
|
|
|
|
|
.in-progress {
|
|
|
|
opacity: 0.6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.has-attachment {
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
2020-05-02 04:17:36 +00:00
|
|
|
|
2020-04-02 06:58:38 +00:00
|
|
|
.user.has-attachment {
|
|
|
|
.icon-wrap {
|
|
|
|
color: $color-white;
|
|
|
|
}
|
|
|
|
|
|
|
|
.download {
|
2020-05-02 04:17:36 +00:00
|
|
|
color: $color-white;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-message-wrap {
|
|
|
|
+ .user-message-wrap {
|
|
|
|
margin-top: $space-micro;
|
|
|
|
|
|
|
|
.user-message .chat-bubble {
|
|
|
|
border-top-right-radius: $space-smaller;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ .agent-message-wrap {
|
|
|
|
margin-top: $space-normal;
|
2020-04-02 06:58:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
|
|
|
</style>
|