Skip to content

Commit 7f8e3cc

Browse files
committed
fix[automation]: handle empty fieldType in the frontend breaking the automation view.
fix: Previously removed operators for Number type field. Fixes #68
1 parent 8acad27 commit 7f8e3cc

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

frontend/src/constants/filterConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ export const FIELD_OPERATORS = {
3838
OPERATOR.GREATER_THAN,
3939
OPERATOR.LESS_THAN
4040
],
41-
NUMBER: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS],
41+
NUMBER: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS, OPERATOR.GREATER_THAN, OPERATOR.LESS_THAN],
4242
}

frontend/src/features/admin/automation/RuleBox.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@
206206
</div>
207207

208208
<!-- Placeholder for spacing -->
209-
<div v-else class="flex-1">
210-
</div>
211-
209+
<div v-else class="flex-1"></div>
212210

213211
<!-- Remove condition -->
214212
<div class="cursor-pointer mt-2" @click.prevent="removeCondition(index)">
@@ -380,6 +378,10 @@ const emitUpdate = () => {
380378
}
381379
382380
const getFieldOperators = (field, fieldType) => {
381+
// Set default field type if not set for backwards compatibility as this field was added later.
382+
if (!fieldType) {
383+
fieldType = fieldTypeConstants.conversation
384+
}
383385
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
384386
return contactCustomAttributes.value[field]?.operators || []
385387
}
@@ -390,6 +392,10 @@ const getFieldOperators = (field, fieldType) => {
390392
}
391393
392394
const getFieldOptions = (field, fieldType) => {
395+
// Set default field type if not set for backwards compatibility as this field was added later.
396+
if (!fieldType) {
397+
fieldType = fieldTypeConstants.conversation
398+
}
393399
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
394400
return contactCustomAttributes.value[field]?.options || []
395401
}
@@ -401,9 +407,14 @@ const getFieldOptions = (field, fieldType) => {
401407
402408
const inputType = (index) => {
403409
const field = ruleGroup.value.rules[index]?.field
404-
const fieldType = ruleGroup.value.rules[index]?.field_type
405410
const operator = ruleGroup.value.rules[index]?.operator
411+
let fieldType = ruleGroup.value.rules[index]?.field_type
406412
if (['contains', 'not contains'].includes(operator)) return 'tag'
413+
414+
// Set default field type if not set for backwards compatibility as this field was added later.
415+
if (!fieldType) {
416+
fieldType = fieldTypeConstants.conversation
417+
}
407418
if (field && fieldType) {
408419
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
409420
return contactCustomAttributes.value[field]?.type || ''

internal/automation/evaluator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (e *Engine) evaluateRule(rule models.RuleDetail, conversation cmodels.Conve
111111
customAttributes map[string]any
112112
)
113113

114-
// Assign default field type if not provided
114+
// Assign default field type if not provided for backward compatibility.
115115
if rule.FieldType == "" {
116116
rule.FieldType = models.FieldTypeConversationField
117117
}

0 commit comments

Comments
 (0)