Send custom_attr key

This commit is contained in:
Fayaz Ahmed 2022-05-25 13:40:11 +05:30
parent 9165c948c5
commit 50018da780
6 changed files with 54 additions and 5 deletions

View file

@ -174,6 +174,10 @@ export default {
type: Array,
default: () => [],
},
customAttributeType: {
type: String,
default: '',
},
},
computed: {
attributeKey: {
@ -216,6 +220,29 @@ export default {
this.$emit('input', { ...payload, query_operator: value });
},
},
custom_attribute_type: {
get() {
if (!this.customAttributeType) return '';
return this.customAttributeType;
},
set() {
const payload = this.value || {};
this.$emit('input', {
...payload,
custom_attribute_type: this.customAttributeType,
});
},
},
},
watch: {
customAttributeType: {
handler(value) {
if (value === 'conversation' || value === 'contact') {
this.value.custom_attribute_type = this.customAttributeType;
} else this.value.custom_attribute_type = '';
},
immediate: true,
},
},
methods: {
removeFilter() {

View file

@ -76,13 +76,14 @@ export const getOperatorTypes = key => {
return operatorMap[key] || OPERATOR_TYPES_1;
};
export const generateCustomAttributeTypes = customAttributes => {
export const generateCustomAttributeTypes = (customAttributes, type) => {
return customAttributes.map(attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: getCustomAttributeInputType(attr.attribute_display_type),
filterOperators: getOperatorTypes(attr.attribute_display_type),
customAttributeType: type,
};
});
};
@ -159,6 +160,7 @@ export const getDefaultConditions = eventName => {
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
custom_attribute_type: '',
},
];
}
@ -168,6 +170,7 @@ export const getDefaultConditions = eventName => {
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
custom_attribute_type: '',
},
];
};

View file

@ -95,7 +95,12 @@ export default {
condition => condition.key === key
);
},
getCustomAttributeType(key) {
const type = this.automationTypes[
this.automation.event_name
].conditions.find(i => i.key === key).customAttributeType;
return type;
},
getConditionDropdownValues(type) {
const {
agents,
@ -257,10 +262,12 @@ export default {
]('contact_attribute');
const conversationCustomAttributeTypes = generateCustomAttributeTypes(
conversationCustomAttributesRaw
conversationCustomAttributesRaw,
'conversation'
);
const contactCustomAttributeTypes = generateCustomAttributeTypes(
contactCustomAttributesRaw
contactCustomAttributesRaw,
'contact'
);
const manifestedCustomAttributes = [

View file

@ -68,6 +68,9 @@
)
"
:show-query-operator="i !== automation.conditions.length - 1"
:custom-attribute-type="
getCustomAttributeType(automation.conditions[i].attribute_key)
"
:v="$v.automation.conditions.$each[i]"
@resetFilter="resetFilter(i, automation.conditions[i])"
@removeFilter="removeFilter(i)"
@ -179,6 +182,7 @@ export default {
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
custom_attribute_type: '',
},
],
actions: [

View file

@ -64,6 +64,9 @@
automation.conditions[i].attribute_key
)
"
:custom-attribute-type="
getCustomAttributeType(automation.conditions[i].attribute_key)
"
:show-query-operator="i !== automation.conditions.length - 1"
:v="$v.automation.conditions.$each[i]"
@resetFilter="resetFilter(i, automation.conditions[i])"
@ -187,7 +190,6 @@ export default {
},
},
mounted() {
this.$store.dispatch('agents/get');
this.manifestCustomAttributes();
this.allCustomAttributes = this.$store.getters['attributes/getAttributes'];
this.formatAutomation(this.selectedResponse);

View file

@ -174,6 +174,12 @@ export default {
},
},
mounted() {
this.$store.dispatch('inboxes/get');
this.$store.dispatch('agents/get');
this.$store.dispatch('contacts/get');
this.$store.dispatch('teams/get');
this.$store.dispatch('labels/get');
this.$store.dispatch('campaigns/get');
this.$store.dispatch('automations/get');
},
methods: {