feat: Adds the ability to have custom view for conversations (#3666)

* feat: Adds the ability to save custom filters and display folders on the sidebar

* Minor fixes

* Review fixes

* Review fixes

* i18n fixes

* Shows conversations when the user click on the folder sidebar item

* Spacing fixes

* Review fixes

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Sivin Varghese
2022-01-17 09:18:54 +05:30
committed by GitHub
parent 290196d43b
commit 4398734bdf
21 changed files with 594 additions and 23 deletions

View File

@@ -5,6 +5,7 @@
:label="label"
:team-id="teamId"
:conversation-type="conversationType"
:custom-views-id="customViewsId"
@conversation-load="onConversationLoad"
>
<pop-over-search />
@@ -54,6 +55,10 @@ export default {
type: String,
default: '',
},
customViewsId: {
type: [String, Number],
default: 0,
},
},
data() {
return {

View File

@@ -83,6 +83,25 @@ export default {
teamId: route.params.teamId,
}),
},
{
path: frontendURL('accounts/:accountId/custom_view/:id'),
name: 'custom_view_conversations',
roles: ['administrator', 'agent'],
component: ConversationView,
props: route => ({ customViewsId: route.params.id }),
},
{
path: frontendURL(
'accounts/:accountId/custom_view/:id/conversations/:conversation_id'
),
name: 'conversations_through_custom_view',
roles: ['administrator', 'agent'],
component: ConversationView,
props: route => ({
conversationId: route.params.conversation_id,
customViewsId: route.params.id,
}),
},
{
path: frontendURL('accounts/:accountId/mentions/conversations'),
name: 'conversation_mentions',

View File

@@ -0,0 +1,97 @@
<template>
<woot-modal :show.sync="show" :on-close="onClose">
<woot-modal-header :header-title="$t('FILTER.CUSTOM_VIEWS.ADD.TITLE')" />
<form class="row" @submit.prevent="saveCustomViews">
<div class="medium-12 columns">
<woot-input
v-model="name"
:label="$t('FILTER.CUSTOM_VIEWS.ADD.LABEL')"
type="text"
:error="
$v.name.$error ? $t('FILTER.CUSTOM_VIEWS.ADD.ERROR_MESSAGE') : ''
"
:class="{ error: $v.name.$error }"
:placeholder="$t('FILTER.CUSTOM_VIEWS.ADD.PLACEHOLDER')"
@blur="$v.name.$touch"
/>
<div class="modal-footer">
<woot-button :disabled="isButtonDisabled">
{{ $t('FILTER.CUSTOM_VIEWS.ADD.SAVE_BUTTON') }}
</woot-button>
<woot-button variant="clear" @click.prevent="onClose">
{{ $t('FILTER.CUSTOM_VIEWS.ADD.CANCEL_BUTTON') }}
</woot-button>
</div>
</div>
</form>
</woot-modal>
</template>
<script>
import { required, minLength } from 'vuelidate/lib/validators';
import alertMixin from 'shared/mixins/alertMixin';
export default {
mixins: [alertMixin],
props: {
filterType: {
type: Number,
default: 0,
},
customViewsQuery: {
type: Object,
default: () => {},
},
},
data() {
return {
show: true,
name: '',
};
},
computed: {
isButtonDisabled() {
return this.$v.name.$invalid;
},
},
validations: {
name: {
required,
minLength: minLength(1),
},
},
methods: {
onClose() {
this.$emit('close');
},
async saveCustomViews() {
this.$v.$touch();
if (this.$v.$invalid) {
return;
}
try {
await this.$store.dispatch('customViews/create', {
name: this.name,
filter_type: this.filterType,
query: this.customViewsQuery,
});
this.alertMessage = this.$t(
'FILTER.CUSTOM_VIEWS.ADD.API.SUCCESS_MESSAGE'
);
this.onClose();
} catch (error) {
const errorMessage = error?.message;
this.alertMessage =
errorMessage || this.$t('FILTER.CUSTOM_VIEWS.ADD.API.ERROR_MESSAGE');
} finally {
this.showAlert(this.alertMessage);
}
},
},
};
</script>