feat: Support respective input types in custom attributes - filters (#4032)
* Support differnt input types in custom attributes * Handle list type custom attributes Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -141,6 +141,12 @@ export default {
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case 'date':
|
case 'date':
|
||||||
return 'date';
|
return 'date';
|
||||||
|
case 'text':
|
||||||
|
return 'plain_text';
|
||||||
|
case 'list':
|
||||||
|
return 'search_select';
|
||||||
|
case 'checkbox':
|
||||||
|
return 'search_select';
|
||||||
default:
|
default:
|
||||||
return 'plain_text';
|
return 'plain_text';
|
||||||
}
|
}
|
||||||
@@ -159,6 +165,47 @@ export default {
|
|||||||
},
|
},
|
||||||
getDropdownValues(type) {
|
getDropdownValues(type) {
|
||||||
const statusFilters = this.$t('CHAT_LIST.CHAT_STATUS_FILTER_ITEMS');
|
const statusFilters = this.$t('CHAT_LIST.CHAT_STATUS_FILTER_ITEMS');
|
||||||
|
const allCustomAttributes = this.$store.getters[
|
||||||
|
'attributes/getAttributesByModel'
|
||||||
|
](this.attributeModel);
|
||||||
|
|
||||||
|
const isCustomAttributeCheckbox = allCustomAttributes.find(attr => {
|
||||||
|
return (
|
||||||
|
attr.attribute_key === type &&
|
||||||
|
attr.attribute_display_type === 'checkbox'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isCustomAttributeCheckbox) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: true,
|
||||||
|
name: this.$t('FILTER.ATTRIBUTE_LABELS.TRUE'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: false,
|
||||||
|
name: this.$t('FILTER.ATTRIBUTE_LABELS.FALSE'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCustomAttributeList = allCustomAttributes.find(attr => {
|
||||||
|
return (
|
||||||
|
attr.attribute_key === type && attr.attribute_display_type === 'list'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isCustomAttributeList) {
|
||||||
|
return allCustomAttributes
|
||||||
|
.find(attr => attr.attribute_key === type)
|
||||||
|
.attribute_values.map(item => {
|
||||||
|
return {
|
||||||
|
id: item,
|
||||||
|
name: item,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'status':
|
case 'status':
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
"is_greater_than": "Is greater than",
|
"is_greater_than": "Is greater than",
|
||||||
"is_lesser_than": "Is lesser than"
|
"is_lesser_than": "Is lesser than"
|
||||||
},
|
},
|
||||||
|
"ATTRIBUTE_LABELS": {
|
||||||
|
"TRUE": "True",
|
||||||
|
"FALSE": "False"
|
||||||
|
},
|
||||||
"ATTRIBUTES": {
|
"ATTRIBUTES": {
|
||||||
"STATUS": "Status",
|
"STATUS": "Status",
|
||||||
"ASSIGNEE_NAME": "Assignee Name",
|
"ASSIGNEE_NAME": "Assignee Name",
|
||||||
|
|||||||
@@ -147,6 +147,12 @@ export default {
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case 'date':
|
case 'date':
|
||||||
return 'date';
|
return 'date';
|
||||||
|
case 'text':
|
||||||
|
return 'plain_text';
|
||||||
|
case 'list':
|
||||||
|
return 'search_select';
|
||||||
|
case 'checkbox':
|
||||||
|
return 'search_select';
|
||||||
default:
|
default:
|
||||||
return 'plain_text';
|
return 'plain_text';
|
||||||
}
|
}
|
||||||
@@ -164,6 +170,44 @@ export default {
|
|||||||
return type.filterOperators;
|
return type.filterOperators;
|
||||||
},
|
},
|
||||||
getDropdownValues(type) {
|
getDropdownValues(type) {
|
||||||
|
const allCustomAttributes = this.$store.getters[
|
||||||
|
'attributes/getAttributesByModel'
|
||||||
|
](this.attributeModel);
|
||||||
|
const isCustomAttributeCheckbox = allCustomAttributes.find(attr => {
|
||||||
|
return (
|
||||||
|
attr.attribute_key === type &&
|
||||||
|
attr.attribute_display_type === 'checkbox'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (isCustomAttributeCheckbox) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: true,
|
||||||
|
name: this.$t('FILTER.ATTRIBUTE_LABELS.TRUE'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: false,
|
||||||
|
name: this.$t('FILTER.ATTRIBUTE_LABELS.FALSE'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCustomAttributeList = allCustomAttributes.find(attr => {
|
||||||
|
return (
|
||||||
|
attr.attribute_key === type && attr.attribute_display_type === 'list'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isCustomAttributeList) {
|
||||||
|
return allCustomAttributes
|
||||||
|
.find(attr => attr.attribute_key === type)
|
||||||
|
.attribute_values.map(item => {
|
||||||
|
return {
|
||||||
|
id: item,
|
||||||
|
name: item,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'country_code':
|
case 'country_code':
|
||||||
return countries;
|
return countries;
|
||||||
|
|||||||
Reference in New Issue
Block a user