2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-01-23 08:37:01 +00:00
|
|
|
<mention-box :items="items" @mention-select="handleMentionClick" />
|
2019-08-14 09:48:44 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2021-01-23 08:37:01 +00:00
|
|
|
import MentionBox from '../mentions/MentionBox.vue';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2021-01-23 08:37:01 +00:00
|
|
|
components: { MentionBox },
|
|
|
|
props: {
|
|
|
|
searchKey: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
cannedMessages: 'getCannedResponses',
|
|
|
|
}),
|
2021-01-23 08:37:01 +00:00
|
|
|
items() {
|
|
|
|
return this.cannedMessages.map(cannedMessage => ({
|
|
|
|
label: cannedMessage.short_code,
|
|
|
|
key: cannedMessage.short_code,
|
|
|
|
description: cannedMessage.content,
|
|
|
|
}));
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-01-19 13:58:40 +00:00
|
|
|
watch: {
|
2021-01-23 08:37:01 +00:00
|
|
|
searchKey() {
|
|
|
|
this.fetchCannedResponses();
|
2021-01-19 13:58:40 +00:00
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
mounted() {
|
2021-01-23 08:37:01 +00:00
|
|
|
this.fetchCannedResponses();
|
2019-11-17 08:45:05 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2021-01-23 08:37:01 +00:00
|
|
|
fetchCannedResponses() {
|
|
|
|
this.$store.dispatch('getCannedResponse', { searchKey: this.searchKey });
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-01-23 08:37:01 +00:00
|
|
|
handleMentionClick(item = {}) {
|
|
|
|
this.$emit('click', item.description);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|