mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
feat: Quickly create canned responses (#5563)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user