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
@@ -61,7 +61,10 @@
@input="resizeTextarea"
/>
</div>
<div class="mb-3 mt-1">
<div
v-if="field.type !== 'text'"
class="mb-3 mt-1"
>
<div
target="blank"
class="text-sm mb-2 inline space-x-2 font-mono"
@@ -161,7 +164,9 @@ export default {
computed: {
fields () {
return this.template.fields.reduce((acc, f) => {
if (f !== this.field && this.isNumberField(f) && (!f.preferences?.formula || !f.preferences.formula.includes(this.field.uuid))) {
const isAllowed = this.field.type === 'text' ? this.isTextField(f) : this.isNumberField(f)
if (f !== this.field && isAllowed && (!f.preferences?.formula || !f.preferences.formula.includes(this.field.uuid))) {
acc.push(f)
}
@@ -179,6 +184,9 @@ export default {
isNumberField (field) {
return field.type === 'number' || (['radio', 'select'].includes(field.type) && field.options?.every((o) => String(o.value).match(/^[\d.-]+$/)))
},
isTextField (field) {
return ['text', 'number', 'select', 'radio', 'cells', 'phone'].includes(field.type)
},
humanizeFormula (text) {
return text.replace(/{{(.*?)}}/g, (match, uuid) => {
const foundField = this.template.fields.find((f) => f.uuid === uuid)