2021-06-29 14:36:40 +00:00
|
|
|
<template>
|
|
|
|
<div class="context-menu">
|
2022-10-06 05:00:15 +00:00
|
|
|
<woot-modal
|
|
|
|
v-if="isCannedResponseModalOpen && showCannedResponseOption"
|
|
|
|
:show.sync="isCannedResponseModalOpen"
|
|
|
|
:on-close="hideCannedResponseModal"
|
|
|
|
>
|
|
|
|
<add-canned-modal
|
|
|
|
:response-content="plainTextContent"
|
|
|
|
:on-close="hideCannedResponseModal"
|
|
|
|
/>
|
|
|
|
</woot-modal>
|
2021-06-29 14:36:40 +00:00
|
|
|
<woot-button
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="more-vertical"
|
2021-06-29 14:36:40 +00:00
|
|
|
color-scheme="secondary"
|
2022-10-16 23:48:32 +00:00
|
|
|
variant="clear"
|
|
|
|
size="small"
|
2021-06-29 14:36:40 +00:00
|
|
|
@click="handleContextMenuClick"
|
|
|
|
/>
|
|
|
|
<div
|
2022-10-06 05:00:15 +00:00
|
|
|
v-if="isOpen && !isCannedResponseModalOpen"
|
2021-06-29 14:36:40 +00:00
|
|
|
v-on-clickaway="handleContextMenuClick"
|
|
|
|
class="dropdown-pane dropdown-pane--open"
|
|
|
|
:class="`dropdown-pane--${menuPosition}`"
|
|
|
|
>
|
|
|
|
<woot-dropdown-menu>
|
|
|
|
<woot-dropdown-item v-if="showCopy">
|
2022-10-06 05:00:15 +00:00
|
|
|
<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>
|
2021-06-29 14:36:40 +00:00
|
|
|
<woot-button
|
|
|
|
variant="clear"
|
|
|
|
size="small"
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="clipboard"
|
2022-10-16 23:48:32 +00:00
|
|
|
color-scheme="secondary"
|
2021-06-29 14:36:40 +00:00
|
|
|
@click="handleCopy"
|
|
|
|
>
|
|
|
|
{{ $t('CONVERSATION.CONTEXT_MENU.COPY') }}
|
|
|
|
</woot-button>
|
|
|
|
</woot-dropdown-item>
|
2022-10-06 05:00:15 +00:00
|
|
|
|
2021-06-29 14:36:40 +00:00
|
|
|
<woot-dropdown-item>
|
|
|
|
<woot-button
|
2022-10-06 05:00:15 +00:00
|
|
|
v-if="showCannedResponseOption"
|
2021-06-29 14:36:40 +00:00
|
|
|
variant="clear"
|
|
|
|
size="small"
|
2022-10-06 05:00:15 +00:00
|
|
|
icon="comment-add"
|
2022-10-16 23:48:32 +00:00
|
|
|
color-scheme="secondary"
|
2022-10-06 05:00:15 +00:00
|
|
|
@click="showCannedResponseModal"
|
2021-06-29 14:36:40 +00:00
|
|
|
>
|
2022-10-06 05:00:15 +00:00
|
|
|
{{ $t('CONVERSATION.CONTEXT_MENU.CREATE_A_CANNED_RESPONSE') }}
|
2021-06-29 14:36:40 +00:00
|
|
|
</woot-button>
|
|
|
|
</woot-dropdown-item>
|
|
|
|
</woot-dropdown-menu>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2022-10-06 05:00:15 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2021-06-29 14:36:40 +00:00
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
2022-10-06 05:00:15 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2021-06-29 14:36:40 +00:00
|
|
|
|
2022-10-06 05:00:15 +00:00
|
|
|
import AddCannedModal from 'dashboard/routes/dashboard/settings/canned/AddCanned';
|
2021-06-29 14:36:40 +00:00
|
|
|
import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem';
|
|
|
|
import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
|
2022-10-06 05:00:15 +00:00
|
|
|
import { copyTextToClipboard } from 'shared/helpers/clipboard';
|
2021-06-29 14:36:40 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2022-10-06 05:00:15 +00:00
|
|
|
AddCannedModal,
|
2021-06-29 14:36:40 +00:00
|
|
|
WootDropdownMenu,
|
|
|
|
WootDropdownItem,
|
|
|
|
},
|
2022-10-06 05:00:15 +00:00
|
|
|
mixins: [alertMixin, clickaway, messageFormatterMixin],
|
2021-06-29 14:36:40 +00:00
|
|
|
props: {
|
2022-10-06 05:00:15 +00:00
|
|
|
messageContent: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
isOpen: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
showCopy: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
menuPosition: {
|
|
|
|
type: String,
|
|
|
|
default: 'left',
|
|
|
|
},
|
2022-10-06 05:00:15 +00:00
|
|
|
showCannedResponseOption: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return { isCannedResponseModalOpen: false };
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
plainTextContent() {
|
|
|
|
return this.getPlainText(this.messageContent);
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleContextMenuClick() {
|
|
|
|
this.$emit('toggle', !this.isOpen);
|
|
|
|
},
|
2022-10-06 05:00:15 +00:00
|
|
|
async handleCopy() {
|
|
|
|
await copyTextToClipboard(this.plainTextContent);
|
|
|
|
this.showAlert(this.$t('CONTACT_PANEL.COPY_SUCCESSFUL'));
|
|
|
|
this.$emit('toggle', false);
|
2021-06-29 14:36:40 +00:00
|
|
|
},
|
|
|
|
handleDelete() {
|
|
|
|
this.$emit('delete');
|
|
|
|
},
|
2022-10-06 05:00:15 +00:00
|
|
|
hideCannedResponseModal() {
|
|
|
|
this.isCannedResponseModalOpen = false;
|
|
|
|
this.$emit('toggle', false);
|
|
|
|
},
|
|
|
|
showCannedResponseModal() {
|
|
|
|
this.isCannedResponseModalOpen = true;
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dropdown-pane {
|
2022-10-16 23:48:32 +00:00
|
|
|
bottom: var(--space-large);
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
.dropdown-pane--left {
|
2022-10-16 23:48:32 +00:00
|
|
|
right: var(--space-minus-small);
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
.dropdown-pane--right {
|
2022-10-16 23:48:32 +00:00
|
|
|
left: var(--space-minus-small);
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
</style>
|