feat: Quickly create canned responses (#5563)
This commit is contained in:
parent
0a9ea6e272
commit
788b766179
5 changed files with 71 additions and 22 deletions
|
@ -100,10 +100,11 @@
|
|||
v-if="isBubble && !isMessageDeleted"
|
||||
:is-open="showContextMenu"
|
||||
:show-copy="hasText"
|
||||
:show-canned-response-option="isOutgoing"
|
||||
:menu-position="contextMenuPosition"
|
||||
:message-content="data.content"
|
||||
@toggle="handleContextMenuClick"
|
||||
@delete="handleDelete"
|
||||
@copy="handleCopy"
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -126,7 +127,6 @@ import alertMixin from 'shared/mixins/alertMixin';
|
|||
import contentTypeMixin from 'shared/mixins/contentTypeMixin';
|
||||
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
||||
import { generateBotMessageContent } from './helpers/botMessageContentHelper';
|
||||
import { copyTextToClipboard } from 'shared/helpers/clipboard';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -408,11 +408,6 @@ export default {
|
|||
this.showAlert(this.$t('CONVERSATION.FAIL_DELETE_MESSSAGE'));
|
||||
}
|
||||
},
|
||||
async handleCopy() {
|
||||
await copyTextToClipboard(this.data.content);
|
||||
this.showAlert(this.$t('CONTACT_PANEL.COPY_SUCCESSFUL'));
|
||||
this.showContextMenu = false;
|
||||
},
|
||||
async retrySendMessage() {
|
||||
await this.$store.dispatch('sendMessageWithData', this.data);
|
||||
},
|
||||
|
|
|
@ -150,7 +150,8 @@
|
|||
},
|
||||
"CONTEXT_MENU": {
|
||||
"COPY": "Copy",
|
||||
"DELETE": "Delete"
|
||||
"DELETE": "Delete",
|
||||
"CREATE_A_CANNED_RESPONSE": "Add to canned responses"
|
||||
}
|
||||
},
|
||||
"EMAIL_TRANSCRIPT": {
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
<template>
|
||||
<div class="context-menu">
|
||||
<woot-modal
|
||||
v-if="isCannedResponseModalOpen && showCannedResponseOption"
|
||||
:show.sync="isCannedResponseModalOpen"
|
||||
:on-close="hideCannedResponseModal"
|
||||
>
|
||||
<add-canned-modal
|
||||
:response-content="plainTextContent"
|
||||
:on-close="hideCannedResponseModal"
|
||||
/>
|
||||
</woot-modal>
|
||||
<woot-button
|
||||
icon="more-vertical"
|
||||
class="button--delete-message"
|
||||
|
@ -8,13 +18,24 @@
|
|||
@click="handleContextMenuClick"
|
||||
/>
|
||||
<div
|
||||
v-if="isOpen"
|
||||
v-if="isOpen && !isCannedResponseModalOpen"
|
||||
v-on-clickaway="handleContextMenuClick"
|
||||
class="dropdown-pane dropdown-pane--open"
|
||||
:class="`dropdown-pane--${menuPosition}`"
|
||||
>
|
||||
<woot-dropdown-menu>
|
||||
<woot-dropdown-item v-if="showCopy">
|
||||
<woot-dropdown-item>
|
||||
<woot-button
|
||||
variant="clear"
|
||||
color-scheme="alert"
|
||||
size="small"
|
||||
icon="delete"
|
||||
@click="handleDelete"
|
||||
>
|
||||
{{ $t('CONVERSATION.CONTEXT_MENU.DELETE') }}
|
||||
</woot-button>
|
||||
</woot-dropdown-item>
|
||||
<woot-button
|
||||
variant="clear"
|
||||
size="small"
|
||||
|
@ -24,15 +45,16 @@
|
|||
{{ $t('CONVERSATION.CONTEXT_MENU.COPY') }}
|
||||
</woot-button>
|
||||
</woot-dropdown-item>
|
||||
|
||||
<woot-dropdown-item>
|
||||
<woot-button
|
||||
v-if="showCannedResponseOption"
|
||||
variant="clear"
|
||||
color-scheme="alert"
|
||||
size="small"
|
||||
icon="delete"
|
||||
@click="handleDelete"
|
||||
icon="comment-add"
|
||||
@click="showCannedResponseModal"
|
||||
>
|
||||
{{ $t('CONVERSATION.CONTEXT_MENU.DELETE') }}
|
||||
{{ $t('CONVERSATION.CONTEXT_MENU.CREATE_A_CANNED_RESPONSE') }}
|
||||
</woot-button>
|
||||
</woot-dropdown-item>
|
||||
</woot-dropdown-menu>
|
||||
|
@ -40,18 +62,27 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import { mixin as clickaway } from 'vue-clickaway';
|
||||
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
||||
|
||||
import AddCannedModal from 'dashboard/routes/dashboard/settings/canned/AddCanned';
|
||||
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem';
|
||||
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
|
||||
import { copyTextToClipboard } from 'shared/helpers/clipboard';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AddCannedModal,
|
||||
WootDropdownMenu,
|
||||
WootDropdownItem,
|
||||
},
|
||||
mixins: [clickaway],
|
||||
mixins: [alertMixin, clickaway, messageFormatterMixin],
|
||||
props: {
|
||||
messageContent: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
isOpen: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -64,22 +95,42 @@ export default {
|
|||
type: String,
|
||||
default: 'left',
|
||||
},
|
||||
showCannedResponseOption: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return { isCannedResponseModalOpen: false };
|
||||
},
|
||||
computed: {
|
||||
plainTextContent() {
|
||||
return this.getPlainText(this.messageContent);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleContextMenuClick() {
|
||||
this.$emit('toggle', !this.isOpen);
|
||||
},
|
||||
handleCopy() {
|
||||
this.$emit('copy');
|
||||
async handleCopy() {
|
||||
await copyTextToClipboard(this.plainTextContent);
|
||||
this.showAlert(this.$t('CONTACT_PANEL.COPY_SUCCESSFUL'));
|
||||
this.$emit('toggle', false);
|
||||
},
|
||||
handleDelete() {
|
||||
this.$emit('delete');
|
||||
},
|
||||
hideCannedResponseModal() {
|
||||
this.isCannedResponseModalOpen = false;
|
||||
this.$emit('toggle', false);
|
||||
},
|
||||
showCannedResponseModal() {
|
||||
this.isCannedResponseModalOpen = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/* TDOD: Remove once MenuComponent supports postions */
|
||||
.dropdown-pane {
|
||||
bottom: var(--space-medium);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,10 @@ export default {
|
|||
},
|
||||
mixins: [alertMixin],
|
||||
props: {
|
||||
responseContent: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
onClose: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
|
@ -73,10 +77,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
shortCode: '',
|
||||
content: '',
|
||||
|
||||
vertical: 'bottom',
|
||||
horizontal: 'center',
|
||||
content: this.responseContent || '',
|
||||
addCanned: {
|
||||
showLoading: false,
|
||||
message: '',
|
||||
|
|
|
@ -157,5 +157,6 @@
|
|||
],
|
||||
"pane-close-outline": "M9.193 9.249a.75.75 0 0 1 1.059-.056l2.5 2.25a.75.75 0 0 1 0 1.114l-2.5 2.25a.75.75 0 0 1-1.004-1.115l1.048-.942H6.75a.75.75 0 1 1 0-1.5h3.546l-1.048-.942a.75.75 0 0 1-.055-1.06ZM22 17.25A2.75 2.75 0 0 1 19.25 20H4.75A2.75 2.75 0 0 1 2 17.25V6.75A2.75 2.75 0 0 1 4.75 4h14.5A2.75 2.75 0 0 1 22 6.75v10.5Zm-2.75 1.25c.69 0 1.25-.56 1.25-1.25V6.749c0-.69-.56-1.25-1.25-1.25h-3.254V18.5h3.254Zm-4.754 0V5.5H4.75c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h9.746Z",
|
||||
"chevron-left-solid": "M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z",
|
||||
"chevron-right-solid": "M8.293 4.293a1 1 0 0 0 0 1.414L14.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414l7-7a1 1 0 0 0 0-1.414l-7-7a1 1 0 0 0-1.414 0Z"
|
||||
"chevron-right-solid": "M8.293 4.293a1 1 0 0 0 0 1.414L14.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414l7-7a1 1 0 0 0 0-1.414l-7-7a1 1 0 0 0-1.414 0Z",
|
||||
"comment-add-outline": "M12.022 3a6.473 6.473 0 0 0-.709 1.5H5.25A1.75 1.75 0 0 0 3.5 6.25v8.5c0 .966.784 1.75 1.75 1.75h2.249v3.75l5.015-3.75h6.236a1.75 1.75 0 0 0 1.75-1.75l.001-2.483a6.517 6.517 0 0 0 1.5-1.077L22 14.75A3.25 3.25 0 0 1 18.75 18h-5.738L8 21.75a1.25 1.25 0 0 1-1.999-1V18h-.75A3.25 3.25 0 0 1 2 14.75v-8.5A3.25 3.25 0 0 1 5.25 3h6.772ZM17.5 1a5.5 5.5 0 1 1 0 11 5.5 5.5 0 0 1 0-11Zm0 1.5-.09.008a.5.5 0 0 0-.402.402L17 3l-.001 3H14l-.09.008a.5.5 0 0 0-.402.402l-.008.09.008.09a.5.5 0 0 0 .402.402L14 7h2.999L17 10l.008.09a.5.5 0 0 0 .402.402l.09.008.09-.008a.5.5 0 0 0 .402-.402L18 10l-.001-3H21l.09-.008a.5.5 0 0 0 .402-.402l.008-.09-.008-.09a.5.5 0 0 0-.402-.402L21 6h-3.001L18 3l-.008-.09a.5.5 0 0 0-.402-.402L17.5 2.5Z"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue