chore: Adds the ability to see the existing filter when we apply a new filter (#6310)

* feat: Adds existing filter to advance filter modal when we apply a filter
This commit is contained in:
Sivin Varghese
2023-01-24 09:10:17 +05:30
committed by GitHub
parent 9782f71bdf
commit af5c71e060
6 changed files with 119 additions and 12 deletions

View File

@@ -1,3 +1,5 @@
import wootConstants from 'dashboard/constants';
export default {
methods: {
setFilterAttributes() {
@@ -38,5 +40,80 @@ export default {
this.filterTypes = [...this.filterTypes, ...customAttributeTypes];
this.filterGroups = [...allFilterGroups, customAttributesFormatted];
},
initializeExistingFilterToModal() {
this.initializeStatusAndAssigneeFilterToModal();
this.initializeInboxTeamAndLabelFilterToModal();
},
initializeStatusAndAssigneeFilterToModal() {
if (this.activeStatus !== '') {
this.appliedFilter.push({
attribute_key: 'status',
attribute_model: 'standard',
filter_operator: 'equal_to',
values: [
{
id: this.activeStatus,
name: this.$t(
`CHAT_LIST.CHAT_STATUS_FILTER_ITEMS.${this.activeStatus}.TEXT`
),
},
],
query_operator: 'and',
custom_attribute_type: '',
});
}
if (this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE.ME) {
this.appliedFilter.push({
attribute_key: 'assignee_id',
filter_operator: 'equal_to',
values: this.currentUserDetails,
query_operator: 'and',
custom_attribute_type: '',
});
}
},
initializeInboxTeamAndLabelFilterToModal() {
if (this.conversationInbox) {
this.appliedFilter.push({
attribute_key: 'inbox_id',
attribute_model: 'standard',
filter_operator: 'equal_to',
values: [
{
id: this.conversationInbox,
name: this.inbox.name,
},
],
query_operator: 'and',
custom_attribute_type: '',
});
}
if (this.teamId) {
this.appliedFilter.push({
attribute_key: 'team_id',
attribute_model: 'standard',
filter_operator: 'equal_to',
values: this.activeTeam,
query_operator: 'and',
custom_attribute_type: '',
});
}
if (this.label) {
this.appliedFilter.push({
attribute_key: 'labels',
attribute_model: 'standard',
filter_operator: 'equal_to',
values: [
{
id: this.label,
name: this.label,
},
],
query_operator: 'and',
custom_attribute_type: '',
});
}
},
},
};

View File

@@ -10,4 +10,8 @@ describe('Test mixin function', () => {
it('should return proper value from bool', () => {
expect(wrapper.vm.setFilterAttributes).toBeTruthy();
});
it('should return proper value from bool', () => {
expect(wrapper.vm.initializeExistingFilterToModal).toBeTruthy();
});
});