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"
|
v-if="isBubble && !isMessageDeleted"
|
||||||
:is-open="showContextMenu"
|
:is-open="showContextMenu"
|
||||||
:show-copy="hasText"
|
:show-copy="hasText"
|
||||||
|
:show-canned-response-option="isOutgoing"
|
||||||
:menu-position="contextMenuPosition"
|
:menu-position="contextMenuPosition"
|
||||||
|
:message-content="data.content"
|
||||||
@toggle="handleContextMenuClick"
|
@toggle="handleContextMenuClick"
|
||||||
@delete="handleDelete"
|
@delete="handleDelete"
|
||||||
@copy="handleCopy"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -126,7 +127,6 @@ import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import contentTypeMixin from 'shared/mixins/contentTypeMixin';
|
import contentTypeMixin from 'shared/mixins/contentTypeMixin';
|
||||||
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
||||||
import { generateBotMessageContent } from './helpers/botMessageContentHelper';
|
import { generateBotMessageContent } from './helpers/botMessageContentHelper';
|
||||||
import { copyTextToClipboard } from 'shared/helpers/clipboard';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -408,11 +408,6 @@ export default {
|
||||||
this.showAlert(this.$t('CONVERSATION.FAIL_DELETE_MESSSAGE'));
|
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() {
|
async retrySendMessage() {
|
||||||
await this.$store.dispatch('sendMessageWithData', this.data);
|
await this.$store.dispatch('sendMessageWithData', this.data);
|
||||||
},
|
},
|
||||||
|
|
|
@ -150,7 +150,8 @@
|
||||||
},
|
},
|
||||||
"CONTEXT_MENU": {
|
"CONTEXT_MENU": {
|
||||||
"COPY": "Copy",
|
"COPY": "Copy",
|
||||||
"DELETE": "Delete"
|
"DELETE": "Delete",
|
||||||
|
"CREATE_A_CANNED_RESPONSE": "Add to canned responses"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"EMAIL_TRANSCRIPT": {
|
"EMAIL_TRANSCRIPT": {
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="context-menu">
|
<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
|
<woot-button
|
||||||
icon="more-vertical"
|
icon="more-vertical"
|
||||||
class="button--delete-message"
|
class="button--delete-message"
|
||||||
|
@ -8,22 +18,13 @@
|
||||||
@click="handleContextMenuClick"
|
@click="handleContextMenuClick"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="isOpen"
|
v-if="isOpen && !isCannedResponseModalOpen"
|
||||||
v-on-clickaway="handleContextMenuClick"
|
v-on-clickaway="handleContextMenuClick"
|
||||||
class="dropdown-pane dropdown-pane--open"
|
class="dropdown-pane dropdown-pane--open"
|
||||||
:class="`dropdown-pane--${menuPosition}`"
|
:class="`dropdown-pane--${menuPosition}`"
|
||||||
>
|
>
|
||||||
<woot-dropdown-menu>
|
<woot-dropdown-menu>
|
||||||
<woot-dropdown-item v-if="showCopy">
|
<woot-dropdown-item v-if="showCopy">
|
||||||
<woot-button
|
|
||||||
variant="clear"
|
|
||||||
size="small"
|
|
||||||
icon="clipboard"
|
|
||||||
@click="handleCopy"
|
|
||||||
>
|
|
||||||
{{ $t('CONVERSATION.CONTEXT_MENU.COPY') }}
|
|
||||||
</woot-button>
|
|
||||||
</woot-dropdown-item>
|
|
||||||
<woot-dropdown-item>
|
<woot-dropdown-item>
|
||||||
<woot-button
|
<woot-button
|
||||||
variant="clear"
|
variant="clear"
|
||||||
|
@ -35,23 +36,53 @@
|
||||||
{{ $t('CONVERSATION.CONTEXT_MENU.DELETE') }}
|
{{ $t('CONVERSATION.CONTEXT_MENU.DELETE') }}
|
||||||
</woot-button>
|
</woot-button>
|
||||||
</woot-dropdown-item>
|
</woot-dropdown-item>
|
||||||
|
<woot-button
|
||||||
|
variant="clear"
|
||||||
|
size="small"
|
||||||
|
icon="clipboard"
|
||||||
|
@click="handleCopy"
|
||||||
|
>
|
||||||
|
{{ $t('CONVERSATION.CONTEXT_MENU.COPY') }}
|
||||||
|
</woot-button>
|
||||||
|
</woot-dropdown-item>
|
||||||
|
|
||||||
|
<woot-dropdown-item>
|
||||||
|
<woot-button
|
||||||
|
v-if="showCannedResponseOption"
|
||||||
|
variant="clear"
|
||||||
|
size="small"
|
||||||
|
icon="comment-add"
|
||||||
|
@click="showCannedResponseModal"
|
||||||
|
>
|
||||||
|
{{ $t('CONVERSATION.CONTEXT_MENU.CREATE_A_CANNED_RESPONSE') }}
|
||||||
|
</woot-button>
|
||||||
|
</woot-dropdown-item>
|
||||||
</woot-dropdown-menu>
|
</woot-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import { mixin as clickaway } from 'vue-clickaway';
|
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 WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem';
|
||||||
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
|
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
|
||||||
|
import { copyTextToClipboard } from 'shared/helpers/clipboard';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
AddCannedModal,
|
||||||
WootDropdownMenu,
|
WootDropdownMenu,
|
||||||
WootDropdownItem,
|
WootDropdownItem,
|
||||||
},
|
},
|
||||||
mixins: [clickaway],
|
mixins: [alertMixin, clickaway, messageFormatterMixin],
|
||||||
props: {
|
props: {
|
||||||
|
messageContent: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
isOpen: {
|
isOpen: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -64,22 +95,42 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'left',
|
default: 'left',
|
||||||
},
|
},
|
||||||
|
showCannedResponseOption: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return { isCannedResponseModalOpen: false };
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
plainTextContent() {
|
||||||
|
return this.getPlainText(this.messageContent);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleContextMenuClick() {
|
handleContextMenuClick() {
|
||||||
this.$emit('toggle', !this.isOpen);
|
this.$emit('toggle', !this.isOpen);
|
||||||
},
|
},
|
||||||
handleCopy() {
|
async handleCopy() {
|
||||||
this.$emit('copy');
|
await copyTextToClipboard(this.plainTextContent);
|
||||||
|
this.showAlert(this.$t('CONTACT_PANEL.COPY_SUCCESSFUL'));
|
||||||
|
this.$emit('toggle', false);
|
||||||
},
|
},
|
||||||
handleDelete() {
|
handleDelete() {
|
||||||
this.$emit('delete');
|
this.$emit('delete');
|
||||||
},
|
},
|
||||||
|
hideCannedResponseModal() {
|
||||||
|
this.isCannedResponseModalOpen = false;
|
||||||
|
this.$emit('toggle', false);
|
||||||
|
},
|
||||||
|
showCannedResponseModal() {
|
||||||
|
this.isCannedResponseModalOpen = true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
/* TDOD: Remove once MenuComponent supports postions */
|
|
||||||
.dropdown-pane {
|
.dropdown-pane {
|
||||||
bottom: var(--space-medium);
|
bottom: var(--space-medium);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,10 @@ export default {
|
||||||
},
|
},
|
||||||
mixins: [alertMixin],
|
mixins: [alertMixin],
|
||||||
props: {
|
props: {
|
||||||
|
responseContent: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
onClose: {
|
onClose: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
|
@ -73,10 +77,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
shortCode: '',
|
shortCode: '',
|
||||||
content: '',
|
content: this.responseContent || '',
|
||||||
|
|
||||||
vertical: 'bottom',
|
|
||||||
horizontal: 'center',
|
|
||||||
addCanned: {
|
addCanned: {
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
message: '',
|
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",
|
"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-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