2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2020-04-17 15:45:20 +00:00
|
|
|
<li v-if="hasAttachments || data.content" :class="alignBubble">
|
2019-08-14 09:48:44 +00:00
|
|
|
<div :class="wrapClass">
|
2020-03-22 10:24:36 +00:00
|
|
|
<p v-tooltip.top-start="sentByMessage" :class="bubbleClass">
|
2019-11-17 07:39:10 +00:00
|
|
|
<bubble-text
|
|
|
|
v-if="data.content"
|
|
|
|
:message="message"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
2020-04-17 15:45:20 +00:00
|
|
|
<span v-if="hasAttachments">
|
|
|
|
<span v-for="attachment in data.attachments" :key="attachment.id">
|
|
|
|
<bubble-image
|
|
|
|
v-if="attachment.file_type === 'image'"
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
|
|
|
<bubble-file
|
|
|
|
v-if="attachment.file_type !== 'image'"
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</span>
|
2019-11-17 07:39:10 +00:00
|
|
|
<i
|
|
|
|
v-if="isPrivate"
|
|
|
|
v-tooltip.top-start="toolTipMessage"
|
|
|
|
class="icon ion-android-lock"
|
|
|
|
@mouseenter="isHovered = true"
|
|
|
|
@mouseleave="isHovered = false"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-11-23 18:59:55 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
import getEmojiSVG from '../emoji/utils';
|
|
|
|
import timeMixin from '../../../mixins/time';
|
|
|
|
import BubbleText from './bubble/Text';
|
|
|
|
import BubbleImage from './bubble/Image';
|
2020-04-02 06:58:38 +00:00
|
|
|
import BubbleFile from './bubble/File';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
BubbleText,
|
|
|
|
BubbleImage,
|
2020-04-02 06:58:38 +00:00
|
|
|
BubbleFile,
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-11-23 18:59:55 +00:00
|
|
|
mixins: [timeMixin, messageFormatterMixin],
|
2019-11-17 07:39:10 +00:00
|
|
|
props: {
|
|
|
|
data: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHovered: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
message() {
|
2019-11-23 18:59:55 +00:00
|
|
|
return this.formatMessage(this.data.content);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
alignBubble() {
|
2020-01-09 07:36:40 +00:00
|
|
|
return !this.data.message_type ? 'left' : 'right';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
readableTime() {
|
|
|
|
return this.messageStamp(this.data.created_at);
|
|
|
|
},
|
|
|
|
isBubble() {
|
2020-01-09 07:36:40 +00:00
|
|
|
return [0, 1, 3].includes(this.data.message_type);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-04-17 15:45:20 +00:00
|
|
|
hasAttachments() {
|
|
|
|
return !!(this.data.attachments && this.data.attachments.length > 0);
|
|
|
|
},
|
2020-03-22 10:24:36 +00:00
|
|
|
hasImageAttachment() {
|
2020-04-17 15:45:20 +00:00
|
|
|
if (this.hasAttachments && this.data.attachments.length > 0) {
|
|
|
|
const { attachments = [{}] } = this.data;
|
|
|
|
const { file_type: fileType } = attachments[0];
|
|
|
|
return fileType === 'image';
|
|
|
|
}
|
|
|
|
return false;
|
2020-03-22 10:24:36 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
isPrivate() {
|
|
|
|
return this.data.private;
|
|
|
|
},
|
|
|
|
toolTipMessage() {
|
2019-11-17 07:39:10 +00:00
|
|
|
return this.data.private
|
|
|
|
? { content: this.$t('CONVERSATION.VISIBLE_TO_AGENTS'), classes: 'top' }
|
|
|
|
: false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
sentByMessage() {
|
2020-07-27 16:49:26 +00:00
|
|
|
const { sender } = this.data;
|
|
|
|
|
|
|
|
return this.data.message_type === 1 && !this.isHovered && sender
|
|
|
|
? {
|
|
|
|
content: `Sent by: ${sender.available_name || sender.name}`,
|
|
|
|
classes: 'top',
|
|
|
|
}
|
2019-11-17 07:39:10 +00:00
|
|
|
: false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
wrapClass() {
|
|
|
|
return {
|
|
|
|
wrap: this.isBubble,
|
|
|
|
'activity-wrap': !this.isBubble,
|
|
|
|
};
|
|
|
|
},
|
2020-03-22 10:24:36 +00:00
|
|
|
bubbleClass() {
|
|
|
|
return {
|
|
|
|
bubble: this.isBubble,
|
|
|
|
'is-private': this.isPrivate,
|
|
|
|
'is-image': this.hasImageAttachment,
|
|
|
|
};
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getEmojiSVG,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-03-22 10:24:36 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~dashboard/assets/scss/variables.scss';
|
|
|
|
.wrap {
|
|
|
|
.is-image {
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.image {
|
|
|
|
max-width: 32rem;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|