text formula

This commit is contained in:
Pete Matsyburka
2026-07-30 10:43:59 +03:00
parent b8c29324b8
commit 5ec8e4ccc7
7 changed files with 69 additions and 11 deletions
+20 -1
View File
@@ -1259,7 +1259,7 @@ export default {
return formulaFields.reduce((acc, f) => {
if (this.conditionalFieldIndex[f.uuid] !== false) {
acc[f.uuid] = this.calculateFormula(f)
acc[f.uuid] = f.type === 'text' ? this.evalTextFormula(f) : this.calculateFormula(f)
}
return acc
@@ -1526,6 +1526,25 @@ export default {
return this.math.evaluate(transformedFormula.toLowerCase())
},
evalTextFormula (field, depth = 0) {
if (depth > 10) return ''
return field.preferences.formula.replace(/{{(.*?)}}/g, (match, uuid) => {
const formulaField = this.fieldsUuidIndex[uuid]
if (formulaField?.preferences?.formula) {
if (formulaField.type === 'text') {
return this.evalTextFormula(formulaField, depth + 1)
} else if (this.isMathLoaded) {
return this.calculateFormula(formulaField)
}
}
const value = formulaField?.default_value
return Array.isArray(value) ? value.join(', ') : (value ?? '')
})
},
hasFormulaDependencyValue (field) {
const normalized = this.normalizeFormula(field.preferences.formula)