fix[automation]: handle empty fieldType in the frontend breaking the automation view.

fix: Previously removed operators for Number type field.
Fixes #68
This commit is contained in:
Abhinav Raut
2025-04-15 21:31:19 +05:30
parent 8acad27b75
commit 7f8e3ccbbc
3 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -38,5 +38,5 @@ export const FIELD_OPERATORS = {
OPERATOR.GREATER_THAN,
OPERATOR.LESS_THAN
],
NUMBER: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS],
NUMBER: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS, OPERATOR.GREATER_THAN, OPERATOR.LESS_THAN],
}
@@ -206,9 +206,7 @@
</div>
<!-- Placeholder for spacing -->
<div v-else class="flex-1">
</div>
<div v-else class="flex-1"></div>
<!-- Remove condition -->
<div class="cursor-pointer mt-2" @click.prevent="removeCondition(index)">
@@ -380,6 +378,10 @@ const emitUpdate = () => {
}
const getFieldOperators = (field, fieldType) => {
// Set default field type if not set for backwards compatibility as this field was added later.
if (!fieldType) {
fieldType = fieldTypeConstants.conversation
}
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
return contactCustomAttributes.value[field]?.operators || []
}
@@ -390,6 +392,10 @@ const getFieldOperators = (field, fieldType) => {
}
const getFieldOptions = (field, fieldType) => {
// Set default field type if not set for backwards compatibility as this field was added later.
if (!fieldType) {
fieldType = fieldTypeConstants.conversation
}
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
return contactCustomAttributes.value[field]?.options || []
}
@@ -401,9 +407,14 @@ const getFieldOptions = (field, fieldType) => {
const inputType = (index) => {
const field = ruleGroup.value.rules[index]?.field
const fieldType = ruleGroup.value.rules[index]?.field_type
const operator = ruleGroup.value.rules[index]?.operator
let fieldType = ruleGroup.value.rules[index]?.field_type
if (['contains', 'not contains'].includes(operator)) return 'tag'
// Set default field type if not set for backwards compatibility as this field was added later.
if (!fieldType) {
fieldType = fieldTypeConstants.conversation
}
if (field && fieldType) {
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
return contactCustomAttributes.value[field]?.type || ''
+1 -1
View File
@@ -111,7 +111,7 @@ func (e *Engine) evaluateRule(rule models.RuleDetail, conversation cmodels.Conve
customAttributes map[string]any
)
// Assign default field type if not provided
// Assign default field type if not provided for backward compatibility.
if rule.FieldType == "" {
rule.FieldType = models.FieldTypeConversationField
}