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
@@ -12,8 +12,8 @@
:to="findPageElementForArea(area)"
>
<FieldArea
v-if="isMathLoaded"
:model-value="calculateFormula(field)"
v-if="isMathLoaded || field.type === 'text'"
:model-value="field.type === 'text' ? evalTextFormula(field) : calculateFormula(field)"
:is-inline-size="isInlineSize"
:field="field"
:area="area"
@@ -95,6 +95,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 = this.readonlyValues[uuid] ?? this.values[uuid]
return Array.isArray(value) ? value.join(', ') : (value ?? '')
})
}
}
}