iachat/app/javascript/dashboard/routes/dashboard/customviews/DeleteCustomViews.vue
Shivam Mishra b3262597c1
fix: vue 3 followup fixes (#10213)
Fixes: CW-3602,  CW-3606, CW-3605, CW-3601, CW-3603, CW-3600, CW-3598

-
[CW-3602](https://linear.app/chatwoot/issue/CW-3602/chat-list-infinite-loader-fetching-only-odd-numbered-pages)
Chat list pagination broken
-
[CW-3606](https://linear.app/chatwoot/issue/CW-3606/saving-greeting-message-is-not-working-in-inbox-settings)
Greetings message not getting saved
-
[CW-3605](https://linear.app/chatwoot/issue/CW-3605/copy-and-paste-image-attachment-not-working-in-widget)
Paste not working on widget
-
[CW-3601](https://linear.app/chatwoot/issue/CW-3601/edit-category-is-not-working-properly)
Edit category not updating
-
[CW-3603](https://linear.app/chatwoot/issue/CW-3603/delete-filter-is-not-working)
Delete filter modal not toggling
-
[CW-3600](https://linear.app/chatwoot/issue/CW-3600/portal-editor-is-not-working-properly)
Portal editor events were flaky
-
[CW-3598](https://linear.app/chatwoot/issue/CW-3598/rearrange-of-pre-chat-form-fields-throws-an-error)
Prechat form re-order bug

---------

Co-authored-by: Vishnu Narayanan <iamwishnu@gmail.com>
2024-10-03 19:59:07 +05:30

115 lines
3.0 KiB
Vue

<script>
import { useAlert } from 'dashboard/composables';
import { CONTACTS_EVENTS } from '../../../helper/AnalyticsHelper/events';
import { useTrack } from 'dashboard/composables';
export default {
props: {
show: {
type: Boolean,
default: false,
},
activeCustomView: {
type: Object,
default: () => {},
},
customViewsId: {
type: [String, Number],
default: 0,
},
activeFilterType: {
type: Number,
default: 0,
},
openLastItemAfterDelete: {
type: Function,
default: () => {},
},
},
emits: ['close', 'update:show'],
computed: {
localShow: {
get() {
return this.show;
},
set(value) {
this.$emit('update:show', value);
},
},
activeCustomViews() {
if (this.activeFilterType === 0) {
return 'conversation';
}
if (this.activeFilterType === 1) {
return 'contact';
}
return '';
},
deleteMessage() {
return ` ${this.activeCustomView && this.activeCustomView.name}?`;
},
deleteConfirmText() {
return `${this.$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.YES')}`;
},
deleteRejectText() {
return `${this.$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.NO')}`;
},
isFolderSection() {
return this.activeFilterType === 0 && this.$route.name !== 'home';
},
isSegmentSection() {
return (
this.activeFilterType === 1 && this.$route.name !== 'contacts_dashboard'
);
},
},
methods: {
async deleteSavedCustomViews() {
try {
const id = Number(this.customViewsId);
const filterType = this.activeCustomViews;
await this.$store.dispatch('customViews/delete', { id, filterType });
this.closeDeletePopup();
useAlert(
this.activeFilterType === 0
? this.$t('FILTER.CUSTOM_VIEWS.DELETE.API_FOLDERS.SUCCESS_MESSAGE')
: this.$t('FILTER.CUSTOM_VIEWS.DELETE.API_SEGMENTS.SUCCESS_MESSAGE')
);
useTrack(CONTACTS_EVENTS.DELETE_FILTER, {
type: this.filterType === 0 ? 'folder' : 'segment',
});
} catch (error) {
const errorMessage =
error?.response?.message || this.activeFilterType === 0
? this.$t('FILTER.CUSTOM_VIEWS.DELETE.API_FOLDERS.SUCCESS_MESSAGE')
: this.$t(
'FILTER.CUSTOM_VIEWS.DELETE.API_SEGMENTS.SUCCESS_MESSAGE'
);
useAlert(errorMessage);
}
this.openLastItemAfterDelete();
},
closeDeletePopup() {
this.$emit('close');
},
},
};
</script>
<template>
<div>
<woot-delete-modal
v-if="localShow"
v-model:show="localShow"
:on-close="closeDeletePopup"
:on-confirm="deleteSavedCustomViews"
:title="$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.TITLE')"
:message="$t('FILTER.CUSTOM_VIEWS.DELETE.MODAL.CONFIRM.MESSAGE')"
:message-value="deleteMessage"
:confirm-text="deleteConfirmText"
:reject-text="deleteRejectText"
/>
</div>
</template>