2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-01-13 12:36:25 +00:00
|
|
|
<div class="reply-box" :class="replyBoxClass">
|
2022-02-07 06:57:20 +00:00
|
|
|
<banner
|
|
|
|
v-if="showSelfAssignBanner"
|
|
|
|
color-scheme="secondary"
|
|
|
|
:banner-message="$t('CONVERSATION.NOT_ASSIGNED_TO_YOU')"
|
|
|
|
:has-action-button="true"
|
|
|
|
:action-button-label="$t('CONVERSATION.ASSIGN_TO_ME')"
|
|
|
|
@click="onClickSelfAssign"
|
|
|
|
/>
|
2021-01-13 13:46:45 +00:00
|
|
|
<reply-top-panel
|
|
|
|
:mode="replyType"
|
|
|
|
:set-reply-mode="setReplyMode"
|
|
|
|
:is-message-length-reaching-threshold="isMessageLengthReachingThreshold"
|
|
|
|
:characters-remaining="charactersRemaining"
|
2021-09-01 13:42:22 +00:00
|
|
|
:popout-reply-box="popoutReplyBox"
|
|
|
|
@click="$emit('click')"
|
2021-01-13 13:46:45 +00:00
|
|
|
/>
|
2021-01-13 12:36:25 +00:00
|
|
|
<div class="reply-box__top">
|
|
|
|
<canned-response
|
2021-01-26 18:34:11 +00:00
|
|
|
v-if="showMentions && hasSlashCommand"
|
|
|
|
v-on-clickaway="hideMentions"
|
|
|
|
:search-key="mentionSearchKey"
|
2021-01-23 08:37:01 +00:00
|
|
|
@click="replaceText"
|
2021-01-13 12:36:25 +00:00
|
|
|
/>
|
|
|
|
<emoji-input
|
|
|
|
v-if="showEmojiPicker"
|
|
|
|
v-on-clickaway="hideEmojiPicker"
|
2022-09-06 05:11:39 +00:00
|
|
|
:class="emojiDialogClassOnExpanedLayout"
|
2021-01-13 12:36:25 +00:00
|
|
|
:on-click="emojiOnClick"
|
|
|
|
/>
|
2021-10-11 07:30:48 +00:00
|
|
|
<reply-email-head
|
|
|
|
v-if="showReplyHead"
|
2021-12-07 18:14:32 +00:00
|
|
|
:cc-emails.sync="ccEmails"
|
|
|
|
:bcc-emails.sync="bccEmails"
|
2021-10-11 07:30:48 +00:00
|
|
|
/>
|
2022-03-04 14:13:07 +00:00
|
|
|
<woot-audio-recorder
|
|
|
|
v-if="showAudioRecorderEditor"
|
|
|
|
ref="audioRecorderInput"
|
2022-05-02 07:44:04 +00:00
|
|
|
@state-recorder-progress-changed="onStateProgressRecorderChanged"
|
2022-03-04 14:13:07 +00:00
|
|
|
@state-recorder-changed="onStateRecorderChanged"
|
2022-05-02 07:44:04 +00:00
|
|
|
@finish-record="onFinishRecorder"
|
2022-03-04 14:13:07 +00:00
|
|
|
/>
|
2021-01-13 12:36:25 +00:00
|
|
|
<resizable-text-area
|
2022-03-04 14:13:07 +00:00
|
|
|
v-else-if="!showRichContentEditor"
|
2021-01-13 12:36:25 +00:00
|
|
|
ref="messageInput"
|
|
|
|
v-model="message"
|
|
|
|
class="input"
|
|
|
|
:placeholder="messagePlaceHolder"
|
|
|
|
:min-height="4"
|
|
|
|
@typing-off="onTypingOff"
|
|
|
|
@typing-on="onTypingOn"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
|
|
|
/>
|
2021-01-18 05:50:19 +00:00
|
|
|
<woot-message-editor
|
|
|
|
v-else
|
|
|
|
v-model="message"
|
2022-09-30 22:03:33 +00:00
|
|
|
:editor-id="editorStateId"
|
2021-01-18 05:50:19 +00:00
|
|
|
class="input"
|
2021-01-26 18:34:11 +00:00
|
|
|
:is-private="isOnPrivateNote"
|
2021-01-18 05:50:19 +00:00
|
|
|
:placeholder="messagePlaceHolder"
|
|
|
|
:min-height="4"
|
|
|
|
@typing-off="onTypingOff"
|
|
|
|
@typing-on="onTypingOn"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
2021-01-26 18:34:11 +00:00
|
|
|
@toggle-user-mention="toggleUserMention"
|
2021-06-02 04:50:40 +00:00
|
|
|
@toggle-canned-menu="toggleCannedMenu"
|
2021-01-18 05:50:19 +00:00
|
|
|
/>
|
2021-01-13 12:36:25 +00:00
|
|
|
</div>
|
2021-11-02 04:35:49 +00:00
|
|
|
<div v-if="hasAttachments" class="attachment-preview-box" @paste="onPaste">
|
2021-01-06 12:26:29 +00:00
|
|
|
<attachment-preview
|
|
|
|
:attachments="attachedFiles"
|
|
|
|
:remove-attachment="removeAttachment"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2022-02-15 05:08:24 +00:00
|
|
|
<div
|
2022-02-25 11:06:10 +00:00
|
|
|
v-if="isSignatureEnabledForInbox"
|
2022-02-15 05:08:24 +00:00
|
|
|
v-tooltip="$t('CONVERSATION.FOOTER.MESSAGE_SIGN_TOOLTIP')"
|
|
|
|
class="message-signature-wrap"
|
|
|
|
>
|
2022-02-25 11:06:10 +00:00
|
|
|
<p
|
|
|
|
v-if="isSignatureAvailable"
|
2022-04-21 05:57:28 +00:00
|
|
|
v-dompurify-html="formatMessage(messageSignature)"
|
2022-02-25 11:06:10 +00:00
|
|
|
class="message-signature"
|
|
|
|
/>
|
|
|
|
<p v-else class="message-signature">
|
|
|
|
{{ $t('CONVERSATION.FOOTER.MESSAGE_SIGNATURE_NOT_CONFIGURED') }}
|
|
|
|
<router-link :to="profilePath">
|
|
|
|
{{ $t('CONVERSATION.FOOTER.CLICK_HERE') }}
|
|
|
|
</router-link>
|
|
|
|
</p>
|
2022-02-15 05:08:24 +00:00
|
|
|
</div>
|
2021-01-13 12:36:25 +00:00
|
|
|
<reply-bottom-panel
|
|
|
|
:mode="replyType"
|
2022-02-15 05:08:24 +00:00
|
|
|
:inbox="inbox"
|
2021-01-13 12:36:25 +00:00
|
|
|
:send-button-text="replyButtonLabel"
|
2022-02-15 10:46:54 +00:00
|
|
|
:on-file-upload="onFileUpload"
|
2021-01-13 12:36:25 +00:00
|
|
|
:show-file-upload="showFileUpload"
|
2022-03-04 14:13:07 +00:00
|
|
|
:show-audio-recorder="showAudioRecorder"
|
2021-01-13 12:36:25 +00:00
|
|
|
:toggle-emoji-picker="toggleEmojiPicker"
|
2022-03-04 14:13:07 +00:00
|
|
|
:toggle-audio-recorder="toggleAudioRecorder"
|
|
|
|
:toggle-audio-recorder-play-pause="toggleAudioRecorderPlayPause"
|
2021-01-13 12:36:25 +00:00
|
|
|
:show-emoji-picker="showEmojiPicker"
|
2022-06-07 12:03:33 +00:00
|
|
|
:on-send="onSendReply"
|
2021-01-13 12:36:25 +00:00
|
|
|
:is-send-disabled="isReplyButtonDisabled"
|
2022-05-02 07:44:04 +00:00
|
|
|
:recording-audio-duration-text="recordingAudioDurationText"
|
2022-03-04 14:13:07 +00:00
|
|
|
:recording-audio-state="recordingAudioState"
|
|
|
|
:is-recording-audio="isRecordingAudio"
|
2021-01-26 18:34:11 +00:00
|
|
|
:is-on-private-note="isOnPrivateNote"
|
|
|
|
:is-format-mode="showRichContentEditor"
|
2022-01-25 02:46:58 +00:00
|
|
|
:enable-multiple-file-upload="enableMultipleFileUpload"
|
2022-06-07 12:03:33 +00:00
|
|
|
:has-whatsapp-templates="hasWhatsappTemplates"
|
|
|
|
@selectWhatsappTemplate="openWhatsappTemplateModal"
|
|
|
|
/>
|
|
|
|
<whatsapp-templates
|
|
|
|
:inbox-id="inbox.id"
|
|
|
|
:show="showWhatsAppTemplatesModal"
|
|
|
|
@close="hideWhatsappTemplatesModal"
|
|
|
|
@on-send="onSendWhatsAppReply"
|
|
|
|
@cancel="hideWhatsappTemplatesModal"
|
2021-01-13 12:36:25 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
2021-04-15 16:58:19 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-09-13 17:19:01 +00:00
|
|
|
import EmojiInput from 'shared/components/emoji/EmojiInput';
|
2019-08-14 09:48:44 +00:00
|
|
|
import CannedResponse from './CannedResponse';
|
2020-06-18 09:47:45 +00:00
|
|
|
import ResizableTextArea from 'shared/components/ResizableTextArea';
|
2021-01-06 12:26:29 +00:00
|
|
|
import AttachmentPreview from 'dashboard/components/widgets/AttachmentsPreview';
|
2021-01-13 12:36:25 +00:00
|
|
|
import ReplyTopPanel from 'dashboard/components/widgets/WootWriter/ReplyTopPanel';
|
2021-10-11 07:30:48 +00:00
|
|
|
import ReplyEmailHead from './ReplyEmailHead';
|
2021-01-13 12:36:25 +00:00
|
|
|
import ReplyBottomPanel from 'dashboard/components/widgets/WootWriter/ReplyBottomPanel';
|
2022-02-07 06:57:20 +00:00
|
|
|
import Banner from 'dashboard/components/ui/Banner.vue';
|
2021-01-13 12:36:25 +00:00
|
|
|
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
|
2021-01-18 05:50:19 +00:00
|
|
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
2022-03-04 14:13:07 +00:00
|
|
|
import WootAudioRecorder from 'dashboard/components/widgets/WootWriter/AudioRecorder';
|
2022-02-15 05:08:24 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2021-04-15 16:58:19 +00:00
|
|
|
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
|
2022-08-23 13:05:31 +00:00
|
|
|
import {
|
|
|
|
MAXIMUM_FILE_UPLOAD_SIZE,
|
|
|
|
MAXIMUM_FILE_UPLOAD_SIZE_TWILIO_SMS_CHANNEL,
|
|
|
|
} from 'shared/constants/messages';
|
2021-11-30 05:15:36 +00:00
|
|
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
2022-06-07 12:03:33 +00:00
|
|
|
import WhatsappTemplates from './WhatsappTemplates/Modal.vue';
|
2022-10-03 22:27:34 +00:00
|
|
|
import { buildHotKeys } from 'shared/helpers/KeyboardHelpers';
|
2020-07-16 19:02:32 +00:00
|
|
|
import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper';
|
2020-08-05 12:16:17 +00:00
|
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
2021-02-07 07:24:32 +00:00
|
|
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
2022-01-27 10:27:22 +00:00
|
|
|
import { DirectUpload } from 'activestorage';
|
2022-02-25 11:06:10 +00:00
|
|
|
import { frontendURL } from '../../../helper/URLHelper';
|
2022-09-06 05:11:39 +00:00
|
|
|
import wootConstants from 'dashboard/constants';
|
2022-10-03 22:27:34 +00:00
|
|
|
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2020-03-05 20:17:37 +00:00
|
|
|
components: {
|
|
|
|
EmojiInput,
|
|
|
|
CannedResponse,
|
2020-06-18 09:47:45 +00:00
|
|
|
ResizableTextArea,
|
2021-01-06 12:26:29 +00:00
|
|
|
AttachmentPreview,
|
2021-01-13 12:36:25 +00:00
|
|
|
ReplyTopPanel,
|
2021-10-11 07:30:48 +00:00
|
|
|
ReplyEmailHead,
|
2021-01-13 12:36:25 +00:00
|
|
|
ReplyBottomPanel,
|
2021-01-18 05:50:19 +00:00
|
|
|
WootMessageEditor,
|
2022-03-04 14:13:07 +00:00
|
|
|
WootAudioRecorder,
|
2022-02-07 06:57:20 +00:00
|
|
|
Banner,
|
2022-06-07 12:03:33 +00:00
|
|
|
WhatsappTemplates,
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
2022-02-15 05:08:24 +00:00
|
|
|
mixins: [
|
|
|
|
clickaway,
|
|
|
|
inboxMixin,
|
|
|
|
uiSettingsMixin,
|
|
|
|
alertMixin,
|
|
|
|
messageFormatterMixin,
|
|
|
|
],
|
2020-08-11 04:27:42 +00:00
|
|
|
props: {
|
2021-08-02 10:37:30 +00:00
|
|
|
selectedTweet: {
|
|
|
|
type: [Object, String],
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
isATweet: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2020-08-11 04:27:42 +00:00
|
|
|
},
|
2021-09-01 13:42:22 +00:00
|
|
|
popoutReplyBox: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-08-11 04:27:42 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
message: '',
|
2020-07-04 08:20:44 +00:00
|
|
|
isFocused: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
showEmojiPicker: false,
|
2021-01-26 18:34:11 +00:00
|
|
|
showMentions: false,
|
2021-01-06 12:26:29 +00:00
|
|
|
attachedFiles: [],
|
2022-03-04 14:13:07 +00:00
|
|
|
isRecordingAudio: false,
|
|
|
|
recordingAudioState: '',
|
2022-05-02 07:44:04 +00:00
|
|
|
recordingAudioDurationText: '',
|
2021-01-13 12:36:25 +00:00
|
|
|
isUploading: false,
|
|
|
|
replyType: REPLY_EDITOR_MODES.REPLY,
|
2021-01-26 18:34:11 +00:00
|
|
|
mentionSearchKey: '',
|
|
|
|
hasUserMention: false,
|
|
|
|
hasSlashCommand: false,
|
2021-12-07 18:14:32 +00:00
|
|
|
bccEmails: '',
|
|
|
|
ccEmails: '',
|
2022-06-07 12:03:33 +00:00
|
|
|
showWhatsAppTemplatesModal: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
2019-11-17 08:45:05 +00:00
|
|
|
computed: {
|
2022-02-07 06:57:20 +00:00
|
|
|
...mapGetters({
|
|
|
|
currentChat: 'getSelectedChat',
|
2022-02-15 05:08:24 +00:00
|
|
|
messageSignature: 'getMessageSignature',
|
2022-02-07 06:57:20 +00:00
|
|
|
currentUser: 'getCurrentUser',
|
2022-02-28 16:12:50 +00:00
|
|
|
lastEmail: 'getLastEmailInSelectedChat',
|
2022-02-15 10:46:54 +00:00
|
|
|
globalConfig: 'globalConfig/get',
|
2022-02-25 11:06:10 +00:00
|
|
|
accountId: 'getCurrentAccountId',
|
2022-02-07 06:57:20 +00:00
|
|
|
}),
|
2021-01-26 18:34:11 +00:00
|
|
|
showRichContentEditor() {
|
2022-09-13 12:41:42 +00:00
|
|
|
if (this.isOnPrivateNote || this.isRichEditorEnabled) {
|
2021-04-16 13:33:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-01-26 18:34:11 +00:00
|
|
|
},
|
2022-02-07 06:57:20 +00:00
|
|
|
assignedAgent: {
|
|
|
|
get() {
|
|
|
|
return this.currentChat.meta.assignee;
|
|
|
|
},
|
|
|
|
set(agent) {
|
|
|
|
const agentId = agent ? agent.id : 0;
|
|
|
|
this.$store.dispatch('setCurrentChatAssignee', agent);
|
|
|
|
this.$store
|
|
|
|
.dispatch('assignAgent', {
|
|
|
|
conversationId: this.currentChat.id,
|
|
|
|
agentId,
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.showAlert(this.$t('CONVERSATION.CHANGE_AGENT'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
showSelfAssignBanner() {
|
|
|
|
if (this.message !== '' && !this.isOnPrivateNote) {
|
|
|
|
if (!this.assignedAgent) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (this.assignedAgent.id !== this.currentUser.id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
2022-06-07 12:03:33 +00:00
|
|
|
hasWhatsappTemplates() {
|
2022-06-10 13:10:29 +00:00
|
|
|
return !!this.$store.getters['inboxes/getWhatsAppTemplates'](this.inboxId)
|
|
|
|
.length;
|
2022-06-07 12:03:33 +00:00
|
|
|
},
|
2020-07-25 17:24:45 +00:00
|
|
|
isPrivate() {
|
2022-08-29 07:10:15 +00:00
|
|
|
if (this.currentChat.can_reply || this.isAWhatsAppChannel) {
|
2021-01-26 18:34:11 +00:00
|
|
|
return this.isOnPrivateNote;
|
2020-07-25 17:24:45 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
inboxId() {
|
|
|
|
return this.currentChat.inbox_id;
|
|
|
|
},
|
|
|
|
inbox() {
|
|
|
|
return this.$store.getters['inboxes/getInbox'](this.inboxId);
|
|
|
|
},
|
|
|
|
messagePlaceHolder() {
|
|
|
|
return this.isPrivate
|
|
|
|
? this.$t('CONVERSATION.FOOTER.PRIVATE_MSG_INPUT')
|
|
|
|
: this.$t('CONVERSATION.FOOTER.MSG_INPUT');
|
|
|
|
},
|
|
|
|
isMessageLengthReachingThreshold() {
|
2021-01-13 13:46:45 +00:00
|
|
|
return this.message.length > this.maxLength - 50;
|
2020-07-16 19:02:32 +00:00
|
|
|
},
|
2021-01-13 13:46:45 +00:00
|
|
|
charactersRemaining() {
|
|
|
|
return this.maxLength - this.message.length;
|
2020-07-16 19:02:32 +00:00
|
|
|
},
|
|
|
|
isReplyButtonDisabled() {
|
2022-01-13 18:54:00 +00:00
|
|
|
if (this.isATweet && !this.inReplyTo && !this.isOnPrivateNote) {
|
2021-08-02 10:37:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
|
2022-03-04 14:13:07 +00:00
|
|
|
if (this.hasAttachments || this.hasRecordedAudio) return false;
|
2021-08-02 10:37:30 +00:00
|
|
|
|
2020-07-16 19:02:32 +00:00
|
|
|
return (
|
2021-08-02 10:37:30 +00:00
|
|
|
this.isMessageEmpty ||
|
2020-07-16 19:02:32 +00:00
|
|
|
this.message.length === 0 ||
|
|
|
|
this.message.length > this.maxLength
|
|
|
|
);
|
|
|
|
},
|
2020-03-05 20:17:37 +00:00
|
|
|
conversationType() {
|
2020-03-09 04:30:11 +00:00
|
|
|
const { additional_attributes: additionalAttributes } = this.currentChat;
|
|
|
|
const type = additionalAttributes ? additionalAttributes.type : '';
|
|
|
|
return type || '';
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
|
|
|
maxLength() {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isPrivate) {
|
|
|
|
return MESSAGE_MAX_LENGTH.GENERAL;
|
|
|
|
}
|
|
|
|
if (this.isAFacebookInbox) {
|
|
|
|
return MESSAGE_MAX_LENGTH.FACEBOOK;
|
|
|
|
}
|
2022-08-29 07:10:15 +00:00
|
|
|
if (this.isAWhatsAppChannel) {
|
2021-05-04 14:01:00 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.TWILIO_WHATSAPP;
|
|
|
|
}
|
2022-03-02 09:39:56 +00:00
|
|
|
if (this.isASmsInbox) {
|
2020-07-16 19:02:32 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.TWILIO_SMS;
|
2020-03-05 20:17:37 +00:00
|
|
|
}
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isATwitterInbox) {
|
2020-03-05 20:17:37 +00:00
|
|
|
if (this.conversationType === 'tweet') {
|
2021-08-02 10:37:30 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.TWEET - this.replyToUserLength - 2;
|
2020-03-05 20:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-16 19:02:32 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.GENERAL;
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
showFileUpload() {
|
|
|
|
return (
|
|
|
|
this.isAWebWidgetInbox ||
|
|
|
|
this.isAFacebookInbox ||
|
2022-08-29 07:10:15 +00:00
|
|
|
this.isAWhatsAppChannel ||
|
2021-08-31 13:36:12 +00:00
|
|
|
this.isAPIInbox ||
|
2021-09-06 18:35:14 +00:00
|
|
|
this.isAnEmailChannel ||
|
2022-03-02 09:39:56 +00:00
|
|
|
this.isASmsInbox ||
|
2021-09-30 20:15:29 +00:00
|
|
|
this.isATelegramChannel
|
2020-07-16 19:02:32 +00:00
|
|
|
);
|
|
|
|
},
|
2020-03-05 20:17:37 +00:00
|
|
|
replyButtonLabel() {
|
2022-10-03 22:27:34 +00:00
|
|
|
let sendMessageText = this.$t('CONVERSATION.REPLYBOX.SEND');
|
2020-03-05 20:17:37 +00:00
|
|
|
if (this.isPrivate) {
|
2022-10-03 22:27:34 +00:00
|
|
|
sendMessageText = this.$t('CONVERSATION.REPLYBOX.CREATE');
|
|
|
|
} else if (this.conversationType === 'tweet') {
|
|
|
|
sendMessageText = this.$t('CONVERSATION.REPLYBOX.TWEET');
|
2020-03-05 20:17:37 +00:00
|
|
|
}
|
2022-10-03 22:27:34 +00:00
|
|
|
const keyLabel = isEditorHotKeyEnabled(this.uiSettings, 'cmd_enter')
|
|
|
|
? '(⌘ + ↵)'
|
|
|
|
: '(↵)';
|
|
|
|
return `${sendMessageText} ${keyLabel}`;
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
2020-07-04 08:20:44 +00:00
|
|
|
replyBoxClass() {
|
|
|
|
return {
|
2021-01-13 12:36:25 +00:00
|
|
|
'is-private': this.isPrivate,
|
2021-01-06 12:26:29 +00:00
|
|
|
'is-focused': this.isFocused || this.hasAttachments,
|
2020-07-04 08:20:44 +00:00
|
|
|
};
|
|
|
|
},
|
2021-01-06 12:26:29 +00:00
|
|
|
hasAttachments() {
|
|
|
|
return this.attachedFiles.length;
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
hasRecordedAudio() {
|
|
|
|
return (
|
|
|
|
this.$refs.audioRecorderInput &&
|
|
|
|
this.$refs.audioRecorderInput.hasAudio()
|
|
|
|
);
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
isRichEditorEnabled() {
|
2022-09-13 12:41:42 +00:00
|
|
|
return this.isAWebWidgetInbox || this.isAnEmailChannel || this.isAPIInbox;
|
2021-01-18 05:50:19 +00:00
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
showAudioRecorder() {
|
|
|
|
return !this.isOnPrivateNote && this.showFileUpload;
|
|
|
|
},
|
|
|
|
showAudioRecorderEditor() {
|
|
|
|
return this.showAudioRecorder && this.isRecordingAudio;
|
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
isOnPrivateNote() {
|
|
|
|
return this.replyType === REPLY_EDITOR_MODES.NOTE;
|
|
|
|
},
|
2021-08-02 10:37:30 +00:00
|
|
|
inReplyTo() {
|
|
|
|
const selectedTweet = this.selectedTweet || {};
|
|
|
|
return selectedTweet.id;
|
|
|
|
},
|
2022-09-06 05:11:39 +00:00
|
|
|
isOnExpandedLayout() {
|
|
|
|
const {
|
|
|
|
LAYOUT_TYPES: { CONDENSED },
|
|
|
|
} = wootConstants;
|
|
|
|
const {
|
|
|
|
conversation_display_type: conversationDisplayType = CONDENSED,
|
|
|
|
} = this.uiSettings;
|
|
|
|
return conversationDisplayType !== CONDENSED;
|
|
|
|
},
|
|
|
|
emojiDialogClassOnExpanedLayout() {
|
|
|
|
return this.isOnExpandedLayout && !this.popoutReplyBox
|
|
|
|
? 'emoji-dialog--expanded'
|
|
|
|
: '';
|
|
|
|
},
|
2021-08-02 10:37:30 +00:00
|
|
|
replyToUserLength() {
|
|
|
|
const selectedTweet = this.selectedTweet || {};
|
|
|
|
const {
|
|
|
|
sender: {
|
|
|
|
additional_attributes: { screen_name: screenName = '' } = {},
|
|
|
|
} = {},
|
|
|
|
} = selectedTweet;
|
|
|
|
return screenName ? screenName.length : 0;
|
|
|
|
},
|
2021-07-27 02:08:27 +00:00
|
|
|
isMessageEmpty() {
|
2021-08-02 10:37:30 +00:00
|
|
|
if (!this.message) {
|
|
|
|
return true;
|
2021-07-27 02:08:27 +00:00
|
|
|
}
|
|
|
|
return !this.message.trim().replace(/\n/g, '').length;
|
|
|
|
},
|
2021-10-14 07:25:46 +00:00
|
|
|
showReplyHead() {
|
|
|
|
return !this.isOnPrivateNote && this.isAnEmailChannel;
|
2021-10-11 07:30:48 +00:00
|
|
|
},
|
2022-01-25 02:46:58 +00:00
|
|
|
enableMultipleFileUpload() {
|
|
|
|
return this.isAnEmailChannel || this.isAWebWidgetInbox || this.isAPIInbox;
|
|
|
|
},
|
2022-02-25 11:06:10 +00:00
|
|
|
isSignatureEnabledForInbox() {
|
2022-02-15 05:08:24 +00:00
|
|
|
return !this.isPrivate && this.isAnEmailChannel && this.sendWithSignature;
|
|
|
|
},
|
2022-02-25 11:06:10 +00:00
|
|
|
isSignatureAvailable() {
|
|
|
|
return !!this.messageSignature;
|
|
|
|
},
|
2022-02-15 05:08:24 +00:00
|
|
|
sendWithSignature() {
|
|
|
|
const { send_with_signature: isEnabled } = this.uiSettings;
|
|
|
|
return isEnabled;
|
|
|
|
},
|
2022-02-25 11:06:10 +00:00
|
|
|
profilePath() {
|
|
|
|
return frontendURL(`accounts/${this.accountId}/profile/settings`);
|
|
|
|
},
|
2022-10-03 22:27:34 +00:00
|
|
|
editorMessageKey() {
|
|
|
|
const { editor_message_key: isEnabled } = this.uiSettings;
|
|
|
|
return isEnabled;
|
|
|
|
},
|
|
|
|
commandPlusEnterToSendEnabled() {
|
|
|
|
return this.editorMessageKey === 'cmd_enter';
|
|
|
|
},
|
|
|
|
enterToSendEnabled() {
|
|
|
|
return this.editorMessageKey === 'enter';
|
2022-09-30 22:03:33 +00:00
|
|
|
},
|
|
|
|
editorStateId() {
|
2022-10-03 22:27:34 +00:00
|
|
|
return `draft-${this.conversationIdByRoute}-${this.replyType}`;
|
2022-09-30 22:03:33 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2022-04-08 10:22:39 +00:00
|
|
|
currentChat(conversation) {
|
2021-01-13 12:36:25 +00:00
|
|
|
const { can_reply: canReply } = conversation;
|
2021-01-26 18:34:11 +00:00
|
|
|
if (this.isOnPrivateNote) {
|
2021-01-19 13:58:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-29 07:10:15 +00:00
|
|
|
if (canReply || this.isAWhatsAppChannel) {
|
2021-01-13 12:36:25 +00:00
|
|
|
this.replyType = REPLY_EDITOR_MODES.REPLY;
|
2020-07-25 17:24:45 +00:00
|
|
|
} else {
|
2021-01-13 12:36:25 +00:00
|
|
|
this.replyType = REPLY_EDITOR_MODES.NOTE;
|
2020-07-25 17:24:45 +00:00
|
|
|
}
|
2022-02-28 16:12:50 +00:00
|
|
|
|
|
|
|
this.setCCEmailFromLastChat();
|
2020-07-25 17:24:45 +00:00
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
message(updatedMessage) {
|
2021-06-02 04:50:40 +00:00
|
|
|
this.hasSlashCommand =
|
|
|
|
updatedMessage[0] === '/' && !this.showRichContentEditor;
|
2020-07-16 19:02:32 +00:00
|
|
|
const hasNextWord = updatedMessage.includes(' ');
|
2021-01-26 18:34:11 +00:00
|
|
|
const isShortCodeActive = this.hasSlashCommand && !hasNextWord;
|
2019-08-14 09:48:44 +00:00
|
|
|
if (isShortCodeActive) {
|
2021-01-26 18:34:11 +00:00
|
|
|
this.mentionSearchKey = updatedMessage.substr(1, updatedMessage.length);
|
|
|
|
this.showMentions = true;
|
2019-08-14 09:48:44 +00:00
|
|
|
} else {
|
2021-01-26 18:34:11 +00:00
|
|
|
this.mentionSearchKey = '';
|
|
|
|
this.showMentions = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2021-09-15 14:45:06 +00:00
|
|
|
|
|
|
|
mounted() {
|
|
|
|
// Donot use the keyboard listener mixin here as the events here are supposed to be
|
|
|
|
// working even if input/textarea is focussed.
|
2021-11-02 04:35:49 +00:00
|
|
|
document.addEventListener('paste', this.onPaste);
|
2022-10-03 22:27:34 +00:00
|
|
|
document.addEventListener('keydown', this.handleKeyEvents);
|
2022-02-28 16:12:50 +00:00
|
|
|
this.setCCEmailFromLastChat();
|
2021-09-15 14:45:06 +00:00
|
|
|
},
|
|
|
|
destroyed() {
|
2021-11-02 04:35:49 +00:00
|
|
|
document.removeEventListener('paste', this.onPaste);
|
2022-10-03 22:27:34 +00:00
|
|
|
document.removeEventListener('keydown', this.handleKeyEvents);
|
2021-09-15 14:45:06 +00:00
|
|
|
},
|
2019-11-17 08:45:05 +00:00
|
|
|
methods: {
|
2022-10-03 22:27:34 +00:00
|
|
|
handleKeyEvents(e) {
|
|
|
|
const keyCode = buildHotKeys(e);
|
|
|
|
if (keyCode === 'escape') {
|
|
|
|
this.hideEmojiPicker();
|
|
|
|
this.hideMentions();
|
|
|
|
} else if (keyCode === 'meta+k') {
|
|
|
|
const ninja = document.querySelector('ninja-keys');
|
|
|
|
ninja.open();
|
|
|
|
e.preventDefault();
|
|
|
|
} else if (keyCode === 'enter' && this.isAValidEvent('enter')) {
|
|
|
|
this.onSendReply();
|
|
|
|
} else if (
|
|
|
|
['meta+enter', 'ctrl+enter'].includes(keyCode) &&
|
|
|
|
this.isAValidEvent('cmd_enter')
|
|
|
|
) {
|
|
|
|
this.onSendReply();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isAValidEvent(selectedKey) {
|
|
|
|
return (
|
|
|
|
!this.hasUserMention &&
|
|
|
|
!this.showCannedMenu &&
|
|
|
|
this.isFocused &&
|
|
|
|
isEditorHotKeyEnabled(this.uiSettings, selectedKey)
|
|
|
|
);
|
|
|
|
},
|
2021-11-02 04:35:49 +00:00
|
|
|
onPaste(e) {
|
|
|
|
const data = e.clipboardData.files;
|
2022-03-23 12:55:57 +00:00
|
|
|
if (!this.showRichContentEditor && data.length !== 0) {
|
|
|
|
this.$refs.messageInput.$el.blur();
|
|
|
|
}
|
2021-11-02 04:35:49 +00:00
|
|
|
if (!data.length || !data[0]) {
|
|
|
|
return;
|
|
|
|
}
|
2022-03-23 12:55:57 +00:00
|
|
|
data.forEach(file => {
|
|
|
|
const { name, type, size } = file;
|
|
|
|
this.onFileUpload({ name, type, size, file: file });
|
|
|
|
});
|
2021-11-02 04:35:49 +00:00
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
toggleUserMention(currentMentionState) {
|
|
|
|
this.hasUserMention = currentMentionState;
|
|
|
|
},
|
2021-06-02 04:50:40 +00:00
|
|
|
toggleCannedMenu(value) {
|
|
|
|
this.showCannedMenu = value;
|
|
|
|
},
|
2022-06-07 12:03:33 +00:00
|
|
|
openWhatsappTemplateModal() {
|
|
|
|
this.showWhatsAppTemplatesModal = true;
|
|
|
|
},
|
|
|
|
hideWhatsappTemplatesModal() {
|
|
|
|
this.showWhatsAppTemplatesModal = false;
|
|
|
|
},
|
2022-02-07 06:57:20 +00:00
|
|
|
onClickSelfAssign() {
|
|
|
|
const {
|
|
|
|
account_id,
|
|
|
|
availability_status,
|
|
|
|
available_name,
|
|
|
|
email,
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
role,
|
|
|
|
avatar_url,
|
|
|
|
} = this.currentUser;
|
|
|
|
const selfAssign = {
|
|
|
|
account_id,
|
|
|
|
availability_status,
|
|
|
|
available_name,
|
|
|
|
email,
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
role,
|
|
|
|
thumbnail: avatar_url,
|
|
|
|
};
|
|
|
|
this.assignedAgent = selfAssign;
|
|
|
|
},
|
2022-06-07 12:03:33 +00:00
|
|
|
async onSendReply() {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isReplyButtonDisabled) {
|
2020-05-17 18:14:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-26 18:34:11 +00:00
|
|
|
if (!this.showMentions) {
|
2022-02-15 05:08:24 +00:00
|
|
|
let newMessage = this.message;
|
2022-02-25 11:06:10 +00:00
|
|
|
if (this.isSignatureEnabledForInbox && this.messageSignature) {
|
2022-02-15 05:08:24 +00:00
|
|
|
newMessage += '\n\n' + this.messageSignature;
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
const messagePayload = this.getMessagePayload(newMessage);
|
2020-07-02 06:28:02 +00:00
|
|
|
this.clearMessage();
|
2022-09-05 10:38:28 +00:00
|
|
|
if (!this.isPrivate) {
|
|
|
|
this.clearEmailField();
|
|
|
|
}
|
2022-06-07 12:03:33 +00:00
|
|
|
this.sendMessage(messagePayload);
|
2019-08-14 09:48:44 +00:00
|
|
|
this.hideEmojiPicker();
|
2021-12-13 07:07:21 +00:00
|
|
|
this.$emit('update:popoutReplyBox', false);
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
2022-06-07 12:03:33 +00:00
|
|
|
async sendMessage(messagePayload) {
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch(
|
|
|
|
'createPendingMessageAndSend',
|
|
|
|
messagePayload
|
|
|
|
);
|
|
|
|
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE);
|
|
|
|
} catch (error) {
|
|
|
|
const errorMessage =
|
|
|
|
error?.response?.data?.error || this.$t('CONVERSATION.MESSAGE_ERROR');
|
|
|
|
this.showAlert(errorMessage);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onSendWhatsAppReply(messagePayload) {
|
|
|
|
this.sendMessage({
|
|
|
|
conversationId: this.currentChat.id,
|
|
|
|
...messagePayload,
|
|
|
|
});
|
|
|
|
this.hideWhatsappTemplatesModal();
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
replaceText(message) {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.message = message;
|
2019-11-17 08:45:05 +00:00
|
|
|
}, 100);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
setReplyMode(mode = REPLY_EDITOR_MODES.REPLY) {
|
|
|
|
const { can_reply: canReply } = this.currentChat;
|
2022-08-29 07:10:15 +00:00
|
|
|
if (canReply || this.isAWhatsAppChannel) this.replyType = mode;
|
2021-02-07 07:24:32 +00:00
|
|
|
if (this.showRichContentEditor) {
|
2022-03-04 14:13:07 +00:00
|
|
|
if (this.isRecordingAudio) {
|
|
|
|
this.toggleAudioRecorder();
|
|
|
|
}
|
2021-08-09 07:38:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-02-07 07:24:32 +00:00
|
|
|
this.$nextTick(() => this.$refs.messageInput.focus());
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
emojiOnClick(emoji) {
|
2020-09-13 17:19:01 +00:00
|
|
|
this.message = `${this.message}${emoji} `;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
clearMessage() {
|
|
|
|
this.message = '';
|
2021-01-06 12:26:29 +00:00
|
|
|
this.attachedFiles = [];
|
2022-09-05 10:38:28 +00:00
|
|
|
this.isRecordingAudio = false;
|
|
|
|
},
|
|
|
|
clearEmailField() {
|
2021-12-07 18:14:32 +00:00
|
|
|
this.ccEmails = '';
|
|
|
|
this.bccEmails = '';
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
toggleEmojiPicker() {
|
|
|
|
this.showEmojiPicker = !this.showEmojiPicker;
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
toggleAudioRecorder() {
|
|
|
|
this.isRecordingAudio = !this.isRecordingAudio;
|
|
|
|
this.isRecorderAudioStopped = !this.isRecordingAudio;
|
|
|
|
if (!this.isRecordingAudio) {
|
|
|
|
this.clearMessage();
|
2022-09-05 10:38:28 +00:00
|
|
|
this.clearEmailField();
|
2022-03-04 14:13:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
toggleAudioRecorderPlayPause() {
|
2022-05-02 07:44:04 +00:00
|
|
|
if (this.isRecordingAudio) {
|
|
|
|
if (!this.isRecorderAudioStopped) {
|
|
|
|
this.isRecorderAudioStopped = true;
|
|
|
|
this.$refs.audioRecorderInput.stopAudioRecording();
|
|
|
|
} else if (this.isRecorderAudioStopped) {
|
|
|
|
this.$refs.audioRecorderInput.playPause();
|
|
|
|
}
|
2022-03-04 14:13:07 +00:00
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
hideEmojiPicker() {
|
|
|
|
if (this.showEmojiPicker) {
|
|
|
|
this.toggleEmojiPicker();
|
|
|
|
}
|
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
hideMentions() {
|
|
|
|
this.showMentions = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-11-26 18:47:55 +00:00
|
|
|
onTypingOn() {
|
|
|
|
this.toggleTyping('on');
|
|
|
|
},
|
|
|
|
onTypingOff() {
|
|
|
|
this.toggleTyping('off');
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
onBlur() {
|
2020-07-04 08:20:44 +00:00
|
|
|
this.isFocused = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-05-04 17:37:56 +00:00
|
|
|
onFocus() {
|
2020-07-04 08:20:44 +00:00
|
|
|
this.isFocused = true;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2022-05-02 07:44:04 +00:00
|
|
|
onStateProgressRecorderChanged(duration) {
|
|
|
|
this.recordingAudioDurationText = duration;
|
2022-03-04 14:13:07 +00:00
|
|
|
},
|
|
|
|
onStateRecorderChanged(state) {
|
|
|
|
this.recordingAudioState = state;
|
2022-05-02 07:44:04 +00:00
|
|
|
if (state && 'notallowederror'.includes(state)) {
|
2022-03-04 14:13:07 +00:00
|
|
|
this.toggleAudioRecorder();
|
|
|
|
}
|
|
|
|
},
|
2022-05-02 07:44:04 +00:00
|
|
|
onFinishRecorder(file) {
|
|
|
|
return file && this.onFileUpload(file);
|
2022-03-04 14:13:07 +00:00
|
|
|
},
|
2019-10-27 13:31:59 +00:00
|
|
|
toggleTyping(status) {
|
2021-08-23 16:04:23 +00:00
|
|
|
const conversationId = this.currentChat.id;
|
2021-11-01 08:20:07 +00:00
|
|
|
const isPrivate = this.isPrivate;
|
2021-08-23 16:04:23 +00:00
|
|
|
this.$store.dispatch('conversationTypingStatus/toggleTyping', {
|
|
|
|
status,
|
|
|
|
conversationId,
|
2021-11-01 08:20:07 +00:00
|
|
|
isPrivate,
|
2021-08-23 16:04:23 +00:00
|
|
|
});
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2022-02-15 10:46:54 +00:00
|
|
|
onFileUpload(file) {
|
|
|
|
if (this.globalConfig.directUploadsEnabled) {
|
|
|
|
this.onDirectFileUpload(file);
|
|
|
|
} else {
|
|
|
|
this.onIndirectFileUpload(file);
|
|
|
|
}
|
|
|
|
},
|
2022-01-27 10:27:22 +00:00
|
|
|
onDirectFileUpload(file) {
|
2022-08-23 13:05:31 +00:00
|
|
|
const MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE = this.isATwilioSMSChannel
|
|
|
|
? MAXIMUM_FILE_UPLOAD_SIZE_TWILIO_SMS_CHANNEL
|
|
|
|
: MAXIMUM_FILE_UPLOAD_SIZE;
|
|
|
|
|
2022-01-27 10:27:22 +00:00
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-23 13:05:31 +00:00
|
|
|
if (checkFileSizeLimit(file, MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE)) {
|
2022-02-01 06:55:51 +00:00
|
|
|
const upload = new DirectUpload(
|
|
|
|
file.file,
|
2022-03-16 08:24:18 +00:00
|
|
|
`/api/v1/accounts/${this.accountId}/conversations/${this.currentChat.id}/direct_uploads`,
|
|
|
|
{
|
|
|
|
directUploadWillCreateBlobWithXHR: xhr => {
|
|
|
|
xhr.setRequestHeader(
|
|
|
|
'api_access_token',
|
|
|
|
this.currentUser.access_token
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}
|
2022-02-01 06:55:51 +00:00
|
|
|
);
|
2022-03-16 08:24:18 +00:00
|
|
|
|
2022-01-27 10:27:22 +00:00
|
|
|
upload.create((error, blob) => {
|
|
|
|
if (error) {
|
2022-02-01 06:55:51 +00:00
|
|
|
this.showAlert(error);
|
2022-01-27 10:27:22 +00:00
|
|
|
} else {
|
2022-02-15 10:46:54 +00:00
|
|
|
this.attachFile({ file, blob });
|
2022-01-27 10:27:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.showAlert(
|
|
|
|
this.$t('CONVERSATION.FILE_SIZE_LIMIT', {
|
2022-08-23 13:05:31 +00:00
|
|
|
MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE,
|
2022-01-27 10:27:22 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-02-15 10:46:54 +00:00
|
|
|
onIndirectFileUpload(file) {
|
2022-08-23 13:05:31 +00:00
|
|
|
const MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE = this.isATwilioSMSChannel
|
|
|
|
? MAXIMUM_FILE_UPLOAD_SIZE_TWILIO_SMS_CHANNEL
|
|
|
|
: MAXIMUM_FILE_UPLOAD_SIZE;
|
2020-04-29 20:11:13 +00:00
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-23 13:05:31 +00:00
|
|
|
if (checkFileSizeLimit(file, MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE)) {
|
2022-02-15 10:46:54 +00:00
|
|
|
this.attachFile({ file });
|
2021-04-15 16:58:19 +00:00
|
|
|
} else {
|
|
|
|
this.showAlert(
|
|
|
|
this.$t('CONVERSATION.FILE_SIZE_LIMIT', {
|
2022-08-23 13:05:31 +00:00
|
|
|
MAXIMUM_SUPPORTED_FILE_UPLOAD_SIZE,
|
2021-04-15 16:58:19 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
},
|
2022-02-15 10:46:54 +00:00
|
|
|
attachFile({ blob, file }) {
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.readAsDataURL(file.file);
|
|
|
|
reader.onloadend = () => {
|
|
|
|
this.attachedFiles.push({
|
|
|
|
currentChatId: this.currentChat.id,
|
|
|
|
resource: blob || file,
|
|
|
|
isPrivate: this.isPrivate,
|
|
|
|
thumb: reader.result,
|
|
|
|
blobSignedId: blob ? blob.signed_id : undefined,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
},
|
2021-01-06 12:26:29 +00:00
|
|
|
removeAttachment(itemIndex) {
|
|
|
|
this.attachedFiles = this.attachedFiles.filter(
|
|
|
|
(item, index) => itemIndex !== index
|
|
|
|
);
|
|
|
|
},
|
|
|
|
getMessagePayload(message) {
|
|
|
|
const messagePayload = {
|
|
|
|
conversationId: this.currentChat.id,
|
|
|
|
message,
|
|
|
|
private: this.isPrivate,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this.inReplyTo) {
|
|
|
|
messagePayload.contentAttributes = { in_reply_to: this.inReplyTo };
|
|
|
|
}
|
|
|
|
|
2022-01-25 02:46:58 +00:00
|
|
|
if (this.attachedFiles && this.attachedFiles.length) {
|
|
|
|
messagePayload.files = [];
|
|
|
|
this.attachedFiles.forEach(attachment => {
|
2022-02-15 10:46:54 +00:00
|
|
|
if (this.globalConfig.directUploadsEnabled) {
|
|
|
|
messagePayload.files.push(attachment.blobSignedId);
|
|
|
|
} else {
|
|
|
|
messagePayload.files.push(attachment.resource.file);
|
|
|
|
}
|
2022-01-25 02:46:58 +00:00
|
|
|
});
|
2021-01-06 12:26:29 +00:00
|
|
|
}
|
|
|
|
|
2022-02-28 16:12:50 +00:00
|
|
|
if (this.ccEmails && !this.isOnPrivateNote) {
|
2021-10-11 07:30:48 +00:00
|
|
|
messagePayload.ccEmails = this.ccEmails;
|
|
|
|
}
|
|
|
|
|
2022-02-28 16:12:50 +00:00
|
|
|
if (this.bccEmails && !this.isOnPrivateNote) {
|
2021-10-11 07:30:48 +00:00
|
|
|
messagePayload.bccEmails = this.bccEmails;
|
|
|
|
}
|
|
|
|
|
2021-01-06 12:26:29 +00:00
|
|
|
return messagePayload;
|
2020-03-22 10:24:36 +00:00
|
|
|
},
|
2021-10-11 07:30:48 +00:00
|
|
|
setCcEmails(value) {
|
|
|
|
this.bccEmails = value.bccEmails;
|
2021-10-14 07:25:46 +00:00
|
|
|
this.ccEmails = value.ccEmails;
|
|
|
|
},
|
2022-02-28 16:12:50 +00:00
|
|
|
setCCEmailFromLastChat() {
|
|
|
|
if (this.lastEmail) {
|
|
|
|
const {
|
|
|
|
content_attributes: { email: emailAttributes = {} },
|
|
|
|
} = this.lastEmail;
|
|
|
|
const cc = emailAttributes.cc || [];
|
|
|
|
const bcc = emailAttributes.bcc || [];
|
|
|
|
this.ccEmails = cc.join(', ');
|
|
|
|
this.bccEmails = bcc.join(', ');
|
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2021-01-13 12:36:25 +00:00
|
|
|
<style lang="scss" scoped>
|
2019-10-27 05:18:26 +00:00
|
|
|
.send-button {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
2021-01-13 12:36:25 +00:00
|
|
|
|
2022-02-15 05:08:24 +00:00
|
|
|
.message-signature-wrap {
|
|
|
|
margin: 0 var(--space-normal);
|
|
|
|
padding: var(--space-small);
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
justify-content: space-between;
|
|
|
|
border: 1px dashed var(--s-100);
|
|
|
|
border-radius: var(--border-radius-small);
|
2022-03-02 09:58:56 +00:00
|
|
|
max-height: 8vh;
|
|
|
|
overflow: auto;
|
2022-02-15 05:08:24 +00:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--s-25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.message-signature {
|
|
|
|
width: fit-content;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2021-01-06 12:26:29 +00:00
|
|
|
.attachment-preview-box {
|
2021-01-13 12:36:25 +00:00
|
|
|
padding: 0 var(--space-normal);
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.reply-box {
|
|
|
|
border-top: 1px solid var(--color-border);
|
|
|
|
background: white;
|
|
|
|
|
|
|
|
&.is-private {
|
|
|
|
background: var(--y-50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.send-button {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.reply-box__top {
|
|
|
|
padding: 0 var(--space-normal);
|
|
|
|
border-top: 1px solid var(--color-border);
|
|
|
|
margin-top: -1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.emoji-dialog {
|
|
|
|
top: unset;
|
|
|
|
bottom: 12px;
|
|
|
|
left: -320px;
|
|
|
|
right: unset;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
right: -16px;
|
|
|
|
bottom: 10px;
|
|
|
|
transform: rotate(270deg);
|
|
|
|
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.08));
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
}
|
2022-09-06 05:11:39 +00:00
|
|
|
.emoji-dialog--expanded {
|
|
|
|
left: unset;
|
|
|
|
bottom: var(--space-jumbo);
|
|
|
|
position: absolute;
|
|
|
|
z-index: var(--z-index-normal);
|
2022-02-25 11:06:10 +00:00
|
|
|
|
2022-09-06 05:11:39 +00:00
|
|
|
&::before {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
left: var(--space-half);
|
|
|
|
bottom: var(--space-minus-slab);
|
|
|
|
}
|
|
|
|
}
|
2022-02-25 11:06:10 +00:00
|
|
|
.message-signature {
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
|
|
::v-deep p:last-child {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
</style>
|