Add labels for Custom attributes in dropdown

This commit is contained in:
Fayaz Ahmed 2022-05-13 15:07:48 +05:30
parent 6730f9fe27
commit 403b4f22ec
3 changed files with 53 additions and 14 deletions

View file

@ -32,6 +32,7 @@
v-for="attribute in filterAttributes"
:key="attribute.key"
:value="attribute.key"
:disabled="attribute.disabled"
>
{{ attribute.name }}
</option>

View file

@ -86,7 +86,9 @@
"RESET_MESSAGE": "Changing event type will reset the conditions and events you have added below"
},
"CONDITION": {
"DELETE_MESSAGE": "You need to have atleast one condition to save"
"DELETE_MESSAGE": "You need to have atleast one condition to save",
"CONTACT_CUSTOM_ATTR_LABEL": "Contact Custom Attributes",
"CONVERSATION_CUSTOM_ATTR_LABEL": "Conversation Custom Attributes"
},
"ACTION": {
"DELETE_MESSAGE": "You need to have atleast one action to save",

View file

@ -396,25 +396,61 @@ export default {
}
},
manifestCustomAttributes() {
const customAttributesRaw = this.$store.getters[
'attributes/getAttributes'
const conversationCustomAttributesRaw = this.$store.getters[
'attributes/getAttributesByModel'
]('conversation_attribute');
const contactCustomAttributesRaw = this.$store.getters[
'attributes/getAttributesByModel'
]('contact_attribute');
const conversationCustomAttributeTypes = conversationCustomAttributesRaw.map(
attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: this.customAttributeInputType(
attr.attribute_display_type
),
filterOperators: this.getOperatorTypes(attr.attribute_display_type),
};
}
);
const contactCustomAttributeTypes = contactCustomAttributesRaw.map(
attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: this.customAttributeInputType(
attr.attribute_display_type
),
filterOperators: this.getOperatorTypes(attr.attribute_display_type),
};
}
);
const manifestedCustomAttributes = [
{
key: 'conversation_custom_attribute',
name: this.$t('AUTOMATION.CONDITION.CONVERSATION_CUSTOM_ATTR_LABEL'),
disabled: true,
},
...conversationCustomAttributeTypes,
{
key: 'contact_custom_attribute',
name: this.$t('AUTOMATION.CONDITION.CONTACT_CUSTOM_ATTR_LABEL'),
disabled: true,
},
...contactCustomAttributeTypes,
];
const customAttributeTypes = customAttributesRaw.map(attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: this.customAttributeInputType(attr.attribute_display_type),
filterOperators: this.getOperatorTypes(attr.attribute_display_type),
};
});
this.automationTypes.message_created.conditions.push(
...customAttributeTypes
...manifestedCustomAttributes
);
this.automationTypes.conversation_created.conditions.push(
...customAttributeTypes
...manifestedCustomAttributes
);
this.automationTypes.conversation_updated.conditions.push(
...customAttributeTypes
...manifestedCustomAttributes
);
},
},