From d038a93d65a208bcb9aac7a0854593002942ddc0 Mon Sep 17 00:00:00 2001 From: fayazara Date: Thu, 15 Dec 2022 18:56:26 +0530 Subject: [PATCH] Truncate long messages --- .../dashboard/i18n/locale/en/search.json | 3 +- .../dashboard/search/components/ReadMore.vue | 15 ++++++---- .../search/components/SearchFocus.vue | 1 + .../components/SearchResultMessageItem.vue | 29 ++++++++++++++++++- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/javascript/dashboard/i18n/locale/en/search.json b/app/javascript/dashboard/i18n/locale/en/search.json index 64be70bda..8f7690df8 100644 --- a/app/javascript/dashboard/i18n/locale/en/search.json +++ b/app/javascript/dashboard/i18n/locale/en/search.json @@ -14,6 +14,7 @@ "EMPTY_STATE": "No %{item} found for query '%{query}'", "PLACEHOLDER_KEYBINDING": "/ to focus", "INPUT_PLACEHOLDER": "Search message content, contact name, email or phone or conversations", - "BOT_LABEL": "Bot" + "BOT_LABEL": "Bot", + "READ_MORE": "Read more" } } diff --git a/app/javascript/dashboard/routes/dashboard/search/components/ReadMore.vue b/app/javascript/dashboard/routes/dashboard/search/components/ReadMore.vue index 3b8aaa6a6..5b22e01bb 100644 --- a/app/javascript/dashboard/routes/dashboard/search/components/ReadMore.vue +++ b/app/javascript/dashboard/routes/dashboard/search/components/ReadMore.vue @@ -1,14 +1,16 @@ @@ -13,9 +19,11 @@ import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue'; import messageFormatterMixin from 'shared/mixins/messageFormatterMixin'; import { mapGetters } from 'vuex'; import { frontendURL } from 'dashboard/helper/URLHelper.js'; +import ReadMore from './ReadMore'; export default { components: { Thumbnail, + ReadMore, }, mixins: [messageFormatterMixin], props: { @@ -24,6 +32,11 @@ export default { default: () => ({}), }, }, + data() { + return { + isOverflowing: false, + }; + }, computed: { messageContent() { return this.formatMessage(this.message.content); @@ -47,6 +60,11 @@ export default { : this.$t('SEARCH.BOT_LABEL'); }, }, + mounted() { + this.$nextTick(() => { + this.isOverflowing = this.$refs.messageContainer.offsetHeight > 150; + }); + }, }; @@ -81,6 +99,15 @@ export default { } &:hover { background-color: var(--s-50); + ::v-deep { + &::after { + background: linear-gradient( + to bottom, + rgba(255, 255, 255, 0), + var(--s-50) 100% + ); + } + } } }