From 185f916b2a73ddfdcd25e54a8e4bd05d9e23b1d6 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 19 Jan 2022 09:40:32 +0530 Subject: [PATCH] feat: Adds the ability to delete the saved custom views (#3780) * feat: Adds the ability to delete the saved custom views * Removed unused tag * Review fixes * Review fixes * Update DeleteCustomViews.vue --- .../dashboard/components/ChatList.vue | 51 ++++++++++-- .../i18n/locale/en/advancedFilters.json | 15 ++++ .../customviews/DeleteCustomViews.vue | 77 +++++++++++++++++++ 3 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 app/javascript/dashboard/routes/dashboard/customviews/DeleteCustomViews.vue diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index 8affb6066..03e5b68bc 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -32,8 +32,20 @@ @click="resetAndFetchData" /> +
+ +
+ + + 0 && this.customViewsId !== 0; + return this.activeCustomView && this.customViewsId !== 0; }, hasAppliedFiltersOrActiveCustomViews() { return this.hasAppliedFilters || this.hasActiveCustomViews; }, savedCustomViewsValue() { if (this.hasActiveCustomViews) { - const payload = this.activeCustomView[0].query; + const payload = this.activeCustomView.query; this.fetchSavedFilteredConversations(payload); } return {}; @@ -275,7 +298,7 @@ export default { return this.$t('CHAT_LIST.MENTION_HEADING'); } if (this.hasActiveCustomViews) { - return this.activeCustomView[0].name; + return this.activeCustomView.name; } return this.$t('CHAT_LIST.TAB_HEADING'); }, @@ -298,11 +321,13 @@ export default { }, activeCustomView() { if (this.customViewsId) { - return this.customViews.filter( + const activeView = this.customViews.filter( view => view.id === Number(this.customViewsId) ); + const [firstValue] = activeView; + return firstValue; } - return []; + return undefined; }, activeTeam() { if (this.teamId) { @@ -352,6 +377,12 @@ export default { onCloseAddCustomViewsModal() { this.showAddCustomViewsModal = false; }, + onClickOpenDeleteCustomViewsModal() { + this.showDeleteCustomViewsModal = true; + }, + onCloseDeleteCustomViewsModal() { + this.showDeleteCustomViewsModal = false; + }, onToggleAdvanceFiltersModal() { this.showAdvancedFilters = !this.showAdvancedFilters; }, @@ -404,7 +435,7 @@ export default { this.$store.dispatch('emptyAllConversations'); this.$store.dispatch('clearConversationFilters'); if (this.hasActiveCustomViews) { - const payload = this.activeCustomView[0].query; + const payload = this.activeCustomView.query; this.fetchSavedFilteredConversations(payload); } if (this.customViewsId) { @@ -422,7 +453,7 @@ export default { this.fetchConversations(); } if (this.hasActiveCustomViews) { - const payload = this.activeCustomView[0].query; + const payload = this.activeCustomView.query; this.fetchSavedFilteredConversations(payload); } else { this.fetchFilteredConversations(this.appliedFilters); @@ -504,4 +535,8 @@ export default { padding: 0 0 var(--space-slab) 0 !important; border-bottom: 1px solid var(--color-border); } + +.delete-custom-view__button { + margin-right: var(--space-normal); +} diff --git a/app/javascript/dashboard/i18n/locale/en/advancedFilters.json b/app/javascript/dashboard/i18n/locale/en/advancedFilters.json index 92a69f0b7..4dc077427 100644 --- a/app/javascript/dashboard/i18n/locale/en/advancedFilters.json +++ b/app/javascript/dashboard/i18n/locale/en/advancedFilters.json @@ -45,6 +45,21 @@ "SUCCESS_MESSAGE": "Custom view created successfully", "ERROR_MESSAGE": "Error while creating custom view" } + }, + "DELETE": { + "DELETE_BUTTON": "Delete filter", + "MODAL": { + "CONFIRM": { + "TITLE": "Confirm Deletion", + "MESSAGE": "Are you sure to delete the filter ", + "YES": "Yes, Delete ", + "NO": "No, Keep " + } + }, + "API": { + "SUCCESS_MESSAGE": "Custom view deleted successfully", + "ERROR_MESSAGE": "Error while deleting custom view" + } } } } diff --git a/app/javascript/dashboard/routes/dashboard/customviews/DeleteCustomViews.vue b/app/javascript/dashboard/routes/dashboard/customviews/DeleteCustomViews.vue new file mode 100644 index 000000000..979a7f9bb --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/customviews/DeleteCustomViews.vue @@ -0,0 +1,77 @@ + + +